A Workaround To A Near Miss Part II

Following on from my previous article here’s a slightly neater way to combine Proc#=== and Symbol#to_proc. No special functions required.

1 case number
2 when lambda( &:even? )
3   puts "Even!"
4 when lambda( &:odd? )
5   puts "Odd!"
6 when lambda( &:zero? )
7   puts "Zero!"
8 end

Farrel Lifson is a lead developer at Aimred.

About Aimred

Aimred is a specialist Ruby and Ruby on Rails development house and consultancy based in Cape Town, South Africa.

We provide Ruby and Ruby on Rails development, consulting and training services to businesses and organisations of all sizes. If you want to find out how we can help you, contact us at info@aimred.com.

Recent Posts

Yearly Archives