The Lambda Lambda Lambda Fraternity

Difficulty:
Easy

Tags:
lambdas, procs, ruby 1.9

Instructions:
Write a proc or lambda that'll take one or two numbers and return true if one or both numbers are even.

Code:
even_check = ___

assert_equal [[2, 4], [1, 2], [8, 12]].select{|arr| even_check.call(*arr)}, [[2, 4], [8, 12]]
assert_equal even_check.call(42), true
assert_equal [[2, 4], [2, 1], [8, 11]].select{|arr| even_check.call(*arr)}, [[2, 4]]

Your Solution

Ruby 1.9.3

Back to Problems