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

May 26, 2015 · 1 min · Jake Worth

Truthy Strings

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

May 26, 2015 · 1 min · Jake Worth

Minmax

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"]

May 18, 2015 · 1 min · Jake Worth

Case Insensitive Matchers

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.

May 15, 2015 · 1 min · Jake Worth

Ruby Symbol#to_proc

What does &: mean in Ruby? In this post, I’ll explain. ...

October 31, 2014 · 2 min · Jake Worth