From: Robert Klemme Date: 2012-08-15T23:50:40+09:00 Subject: Re: Variable in string in array On Wed, Aug 15, 2012 at 2:46 PM, Dave Castellano wrote: > Anybody know how to embed a #{} in a string and then place the string in > an array? > > eg. > > array =["An #{age} year old..."] > > returns > /Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby.tmbundle/Support/RubyMate/catch_exception.rb:15 If the error originated in that line it can only be caused by invoking method "age". Do you have a stack trace? > I tried adding single quotes > array =[' "An #{age} year old..." '] and this accepted the string but > the variable was also converted to a string, so lost as a variable. Do you want the #{...} to be literally present in the String or do you want to evaluate it when placing the String in the Array? Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/