From: Lake Denman Date: 2011-08-31T22:32:09+09:00 Subject: Re: Prepend a character to a string in ruby The other answers are better. I am just posting this for yet another way to prepend text to a string: String interpolation. question = "Nancy Francis: Back here live at the Waterfront Village with my friend the zombie, Jonathon. You’re looking good, Jonathon. Jonathon just got an awesome face paint job. What do you think?\n\n" answer = "Jonathan: I like turtles!" dialogue = "#{question}#{answer}" On Wed, Aug 31, 2011 at 08:00:40PM +0900, 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 > > -- > Posted via http://www.ruby-forum.com/. >