Hacker News new | past | comments | ask | show | jobs | submit login

It is very difficult to read this method.

The more standard way goes from top to bottom. The lambda method requires the reader to go to the bottom of the statement, then to the top and downward. It requires the writer to remember the idiom and it's a barrier to newer developers.

I also don't see the win in doing this either. Sure, somebody can forget to set the return value, but you can also screw up with the other idiom. That part seems like a wash to me.

* edit - Grammatical corrections and reformatting.




I should explain a little more. You never actually see the lambda method, the RewriteRails plugin works a little like Lisp's macros. You write:

    returning [1] do |numbers|
      numbers << 2
      numbers += [3]
    end
And that's all you see in your source code. RewriteRails rewrites that into:

    lambda do |numbers|
      numbers << 2
      numbers += [3]
      numbers
    end.call([1])
And that's what the ruby interpreter sees. But you need never look at the "ugly" rewritten version, just what you wrote.


I can see that as an improvement. Thanks for the follow up.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: