From: SB Date: 2006-01-09T23:49:15+09:00 Subject: use of "return" ------=_Part_28273_30927853.1136818142906 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline This is a total newbie question, but I'd like to know how "return" is specifically used in ruby. From my understanding, it can be avoided in a lot of cases since ruby returns the last value by default. However, some of the code in the Rails stuff I'm looking at has "return" an= d I was wondering if this "return" is necessary or just the individual programmer's style (maybe carried over from other languages). Sorry, I'm vague but I would like to know how "return" is effectively used in ruby if at all. Here's a code snippet from the SaltedHash Engine def new_security_token(hours =3D nil) write_attribute('security_token', AuthenticatedUser.hashed( self.salted_password + Time.now.to_i.to_s + rand.to_s)) write_attribute('token_expiry', Time.at(Time.now.to_i + token_lifetime(hours))) update_without_callbacks return self.security_token end or this: def authenticate(login, pass) u =3D find(:first, :conditions =3D> ["login =3D ? AND verified =3D = 1 AND deleted =3D 0", login]) return nil if u.nil? find(:first, :conditions =3D> ["login =3D ? AND salted_password =3D= ? AND verified =3D 1", login, AuthenticatedUser.salted_password(u.salt, AuthenticatedUser.hashed(pass))]) end Sorry if my question's off the wall. Still finding my bearings. ------=_Part_28273_30927853.1136818142906--