So, this morning when sitting down to investigate The Drunken Cockroach Problem I thought to myself, I don’t want to write any more boilerplate code than I have to, so here’s my CoffeeScript-style constructor function in Ruby:
I stuck with the word initialize as its consistent with Ruby’s #initialize method.
The above code does not override Ruby’s own #initialize method which lives at the instance level and is called by the constructing class. It creates a class-level instance method. No conflicts or collissions going on.
blog comments powered by Disqus