Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Interpolation with expression

  • interpolation
  • capitalize

Ruby allows us to include more complex expression in the interpolation, for exampl to call the capitalize method of a string. It is nice, but don't put anything complex in there!


person = 'foo'

puts "Hello #{person.capitalize}, how are you?"
Hello Foo, how are you?