Technology Agnostic Rubyist : Open Source Lights The Way

Tuesday, December 18, 2012

begin #dosomething rescue false end

I'm becoming a fan of the following Ruby code idiom, where a single line of code evaluates whether something is true or false.

def interrogative_function?(args)
    begin 1==1 rescue false end
end

No comments:

Tweets

Contributors