DEV Community

Discussion on: Level Up Your Ruby Skillz: Writing Compact Code

Collapse
 
abraham profile image
Abraham Williams

One small optimization I like is when chaining methods:

array.select{|n| n.even?}

can be shortened to:

array.select(&:even?)
Collapse
 
molly profile image
Molly Struve (she/her)

100% Thanks for pointing that out! I copied it from the other tutorial without even thinking that I should optimize it. Good call.