From: Robert Klemme Date: 2006-01-10T00:53:02+09:00 Subject: Re: use of "return" Dirk Meijer wrote: > hi, > 'return' is used to return a value, and end the method processing. > at the end of a method, 'return' is indeed not needed, and simply > that value will suffice, though i think a return looks nicer ;-) > a good example where a return is needed, is this: > > def method(arg) > if arg.class==String > return "invalid argument" > end > #rest of processing > end > > this looks a lot nicer than placing your entire method in if/else > code. greetings, Dirk. In this case you wouldn't use return values to flag this error. It's is a typical case for exceptions. def mett(arg) raise ArgumentError, "#{arg.inspect} is not a String" unless String === arg # further processing end And taking this even further, in the light of Duck Typing (TM) usually no type checks of this kind are made at all. :-) Kind regards robert