From: Logan Capaldo Date: 2006-07-21T11:03:05+09:00 Subject: Re: How to truncate strings in Ruby? On Jul 20, 2006, at 9:54 PM, Marston A. wrote: > So I'd think this is a very simple question, I've searched around the > manual and google but couldn't really find it. > > So what is the method to truncate a string in Ruby? Similar to the > truncate(@text, 20) helper method in Rails? To get the first 20 > characters of a string for example. Thanks in advanced > > -- > Posted via http://www.ruby-forum.com/. > @text[0...20] @text[0, 20] @text.slice(0, 20) @text.slice!(0, 20) # modifies @text in place to become it's "truncation"