The Ennnnnd

July 19, 2011

In other programming language news, here’s one proposal for Ruby:

I’d like to propose introducing a special keyword, en(n+)d. Using this keyword, we can rewrite the above example like this:

module MyModule
  class MyClass
    def my_method
      10.times do
        if rand < 0.5 
          p :small

I.e., for each block1 to close, insert another n within end.

It’s so crazy, it almost makes sense. Per Tay, perhaps the best argument again this:

Yeah, I don’t like this change. Mostly because that huge chain of ends is supposed to look ugly; it reminds me that my code is far too nested, and should be reworked and written properly.

I’d prefer bad code to look ugly.

Hiding bad code doesn’t make it go away. (Huge try/catch blocks, anyone?)

But hey, this would work for XML, too!


Just sayin’.

(via @shadowofged)

  1. Not in the sense of Ruby’s blocks.