From: bbiker Date: 2006-07-16T01:35:04+09:00 Subject: Re: Newb: an explaination for this if statement.. Jeff Cohen wrote: > Dominic Son wrote: > > Hi. I'm confused as to why this variable* is nessesary: > > > > ----------- > > > > def add_product(product) > > [snip] > > > existing_product* > > > > end > > In Ruby, the last expression executed becomes the return value of the > method. > > The code could have said: > > return existing_product > > but the "return" keyword is actually optional in this case. > > Jeff > softiesonrails.com > So why not just use "return existing_product" it definetily states its intent also implies that the return value should be caught. lots of methods can return values that do not need to be caught such as puts which always returns nil