watch this  

the official mrchucho blog

Clever Ruby Idiom

Posted 2006 Sep 23
Whilst whipping-up another Rbot plugin yesterday, I wanted to concisely say “sometimes do something”. I found this at Ruby Garden
def sometimes
    yield if rand > 0.5
Now I can do this:
sometimes do

I love that!

Responses to "Clever Ruby Idiom"

No responses yet.

Comments are now closed.
atom rss