Just a Nifty Meta-Meta Tidbit
Sometimes you just write a piece of code that makes you feel like you should give it a violently animating background. I'm just not that cool, though, so I'll just go with my usual syntax coloring:
def hashtastic(value) (Proc === value) ? lambda { |h,k| h[k] = Hash.new(&value) } : lambda { |h,k| h[k] = value } end a = Hash.new(&hashtastic(hashtastic(hashtastic({})))) b = a[0] c = b[0] d = c[0] p a
Try it out. I think you'll find you like it. Enjoy!
Labels: Metaprogramming, Ruby
0 Comments:
Post a Comment
<< Home