From: Stefano Crocco Date: 2011-08-31T20:06:51+09:00 Subject: Re: Prepend a character to a string in ruby On Wednesday 31 August 2011 20:00:40 ruby rails wrote: > Hi, > > I am trying to insert a character to a string at the beginning of a > string. How is it possible in ruby. > I tried using > s.times do |s| > @space_availability+="0" > end > But this would add at the end of the string. > The @space_availability is a string with 1's and 0's. I need to add 0's > at the beginning of this string. > I am a newbie in ruby @space_availlability.insert 0, "0" You can find documentation for a class or method using the ri command line tool: ri String or ri String#insert I hope this helps Stefano