I cannot get foo.[3] to work:

syntax error, unexpected '['

But please don't spend too much time explaining what I'm doing wrong, because I'm afraid I don't like foo.[3] anyway. :)

Let me demonstrate my problem by taking a simulated tour through my brain as it encounters foo.[3] for the first time:

"WTF?

"Did someone mistype foo[3]?

"No, wait, surely it's supposed to be foo(3). I'm pretty sure that foo is a function. Didn't we set it equal to a lambda expression three lines ago?

"Maybe I need glasses. Let's adjust my monitor. No, those are square brackets, all right. And that really is a period between "foo" and the brackets.

"Maybe Google can help. But I'm not sure how to google '.[]'

"Oh, no -- is this one of those mysterious edge cases of the Ruby syntax? Do I hear _Why laughing at me? Does foo.[] magically target the eigenclass, or the metaclass, or the zetaclass, or something? Or did one of the libraries secretly redefine the core language behind my back?

"omigod, I should have learned Python.

"No, wait! The dot means that we're calling a method. And I know that [] is a method -- we redefine it all the time. So foo.[3] is just an obscure-ass way of calling foo[3] .

"Which makes no sense, because I thought foo was a function. So I must be wrong.

"WTF?"

[ten minutes later]

"Aargh! I went through ten minutes of confusion just to save three characters?"

I may have exaggerated this a little. And, yet, I really did have no idea that .[] works, and I still have no idea how it works. (Of course, in my version of Ruby, it apparently doesn't work, which makes it hard to investigate.)

Now, don't get me wrong -- Ruby is my favorite programming language. Quite often, after the tortured syntax, the monkey-patched class, or the strange new DSL stops you dead in your tracks, you'll struggle through the learning curve and discover that you have a powerful new technique. This starts on day zero of Ruby, when you see your first block. It looks like nothing on Earth, but it turns out to be insanely great.

Symbol#to_proc is a borderline case. I like the idea, but I hate the syntax. The &: doesn't bother me as much as the lack of curly brackets. To me, idiomatic Ruby is about blocks -- I expect map() and inject() and delete_if() to take blocks, not arguments. I would really prefer this:

my_array.map {_.get_funky}

Reading this makes me happy. There's a map() call, so I expect a block, and look -- there are the curly brackets. And because it's a block, the stuff inside it must be a method call. And, in fact, the underscore and the dot mean that we're invoking a method on a placeholder. All is well with the world, and no higher brain functions need to be engaged.

But, you know, life isn't perfect. Language is about communication, and ultimately the language you speak is determined by what other people are speaking. Symbol#to_proc is powerful enough to become popular, and popular enough to be idiomatic, so we all have to learn it. Perhaps I'll even start using it.

But I'm afraid String#to_proc, like foo.[x], is past the point of diminishing returns. Do I really need a version of lambda that is not only utterly unlike Ruby's usual lambda, but is even less like Scheme's lambda? And are my colleagues really going to forgive me for asking them to learn Haskell syntax in order to read something as trivial as lambda {|x,y| x+y} ? I'm not even sure if I could forgive myself!