Puts Multiple Lines
Ruby’s puts can take multiple arguments! 2.2.0 :002 > puts 'so', 'many', 'statements', 'to', 'puts' so many statements to puts => nil
Ruby’s puts can take multiple arguments! 2.2.0 :002 > puts 'so', 'many', 'statements', 'to', 'puts' so many statements to puts => nil
Ruby strings are truthy, and they evaluate to zero, unless they start with a number. > 'nine to five'.to_i => 0 > '9 to 5'.to_i => 9
Ruby’s Enumerable class includes minmax, which returns a two element array with the minimum and maximum values of an enumerable. > [1, 5, 10].minmax => [1, 10] > ['alpha', 'bravo', 'zulu'].minmax => ["alpha", "zulu"]
You can make Ruby regex matchers case insensitive with an i. 2.1.0 :001 > 'Expected output' =~ /expected/ => nil 2.1.0 :002 > 'Expected output' =~ /expected/i => 0 This is useful when writing tests, when you care about a message, but are not interested in its exact format.
What does &: mean in Ruby? In this post, I’ll explain. ...