Ruby: Calling variable from array? -


how call variable array? trying make this:

hello_world = "hey" array = [ '#{hello_world} ho' ] array.each |a|   puts end 

say ["hey ho"] instead of ["\#{hello_world} ho"].

do below -

hello_world = "hey" array = [ "#{hello_world} ho" ] array # => ["hey ho"] array.each |a|   p end # >> "hey ho" 

single-quoted strings disabling interpolation, double-quote strings allow interpolation.

remember - interpolation may disabled escaping “#” character or using single-quote strings:

'#{1 + 1}' #=> "\#{1 + 1}" 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -