Hacker News new | ask | show | jobs
by gls2ro 1441 days ago
(not trying to convince you as I think in this thread no one will be convinced of anything)

Knowing that in Ruby a method will always return its last executed line unless explicitly returned early makes (at least for me) things very easy to get.

A method with two branches will always return the last line of the executed branch, thus you will always know what the response could be.

But this (IMO) is because Ruby OOP where the main concept is that when you are invoking a method you are actually sending a message to that object thus you should get a response. So Ruby makes this way of working with objects universal.

Once you call a method you will get a response.

I find it strange the other way around, working in languages where I need to put return even on the last line of the method. For example after almost one year of full time backend development in Ruby, I needed to write some JS code. I debugged for half an hour why a short function that I wrote was not working properly until I got it: I need to add 'return' to that last line to get the actual result. This was strange for me :)