Last Updated: February 25, 2016
·
660
· glucero

instance, class and global variables in strings

the curly braces for instance, class and global variables are optional for string interpolation:

local = 'pie'
@instance = 'makes'
@@class = 'me'
$global = 'happy'

# note the missing curly braces 
puts "#{local} #@instance #@@class #$global"
  => pie makes me happy