From: Sean O'Halpin Date: 2007-10-20T08:32:59+09:00 Subject: Re: Is it always the norm to skip 'return'? ------=_Part_5430_26792817.1192836779804 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 10/19/07, Tito Ciuro wrote: > > Hello, > > I have a question about skipping the 'return' keyword in a Ruby method. [snip] Why so many Ruby snippets skip the 'return' keyword? > > Thanks, > > -- Tito > -- > Because it's not needed and it's considered bad style to introduce unnecessary noise in Ruby. Every method call returns a value. In the absence of a return statement, it is the value of the last expression in the definition. So, whether you want it or not, it happens. Better to get used to that, take advantage of it and save yourself a few keystrokes than to think that you typing return at the end of a method definition makes any difference at all. The only time to use return is when you return from the middle of a method, but even that is considered bad programming practice (functions should have only one exit). Regards, Sean ------=_Part_5430_26792817.1192836779804--