On Wed, Aug 15, 2012 at 2:46 PM, Dave Castellano <[email protected]> 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/
-- You received this message because you are subscribed to the Google Groups
ruby-talk-google group. To post to this group, send email to
[email protected]. To unsubscribe from this group, send email
to [email protected]. For more options, visit this
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en