I know there are people out there who love the way Ruby does some things, but there's one feature of Ruby that drives me nuts, mostly because it doesn't do things The One True Way of Python. And that's call by reference.

In Python, everything is a reference. Let's say you have some methods, and you need to know which one to call. This makes processor case statements easy:

def whichparam(parameter):
    def foo:
        pass

    def bar:
        pass

    def baz:
        pass

    return { 'withone': foo,
             'withtwo': bar,
             'withyou': baz }.get(parameter, baz)()

This case statement will, based on the parameter passed in, execute the function and bubble the value back up to the return statement. This is an incredibly useful technique when you have a finite number of switchable formats or rendering tools that you want to invoke based on user input. More advanced techniques using closure and the automatic generation of function objects is also possible, but not the scope of this post.

It seems to me that, although it's supposedly at the core of Ruby's thinking, the whole proc and .call() syntax looks tacked on to the end. It's messy and inelegant and definitely needs something better. So far, compared to the incredible power of Python closures and its flat variable namespace, Ruby isn't winning me over.

Am I just missing something? Is there some special Ruby sauce for doing what seems to come so naturally in Python? Admittedly, the lack of anonymous functions in Python is something that also annoys me, but not as much; the whitespace-as-delimiter actually makes that tolerable because it makes defining the name short and sweet.