February 2, 2004 Intro to Ruby Slide #7
Prev Next

Variable Interpolation

Variable interpolation is done with the #{} operator:
     fruit = "apple"
     puts "I like #{fruit} pie"

You can put arbitrary code inside the {}'s:
     puts "I'd like #{Math::PI/2} slices of pie."


Prev Copyright © 2004 Walter C. Mankowski Next