Tuesday, December 6, 2016

And this is crazy . . . .

   Just a bit of Ruby silliness to brighten your day.  You can save this to a file (like, oh, say, carly.rb), and run it a bunch of times, or you can just paste it into irb and run just the last line a bunch of times.
me = ->{42}
class Proc
  def maybe
    rand(2)==0 ? self : ->{}
  end
end
def call(it)
  it.call
end
puts call me.maybe

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.