Ruby, iOS, and Other Development

A place to share useful code snippets, ideas, and techniques

All code in posted articles shall be considered public domain unless otherwise noted.
Comments remain the property of their authors.

2007-05-15

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: ,

0 Comments:

Post a Comment

<< Home