From: Logan Capaldo Date: 2006-09-25T13:18:43+09:00 Subject: Re: Riddle me this (a question about expressions) On Mon, Sep 25, 2006 at 12:34:27PM +0900, Rick DeNatale wrote: > On 9/24/06, dblack@wobblini.net wrote: > >Hi -- > > > >On Mon, 25 Sep 2006, Hal Fulton wrote: > > > > >> > >> Nevertheless I think it's significant that raise is a method > >> whereas return (of course) is not. > > > >I think so too. I would not want to see a method call of any kind be > >dealt with as a syntax error just because it has an assignment to its > >left. Since return can't really be a method (at least my brain can't > >wrap itself around that concept :-) I don't think that the two of them > >need to be thought of together with regard to the syntax-error matter. > > > >> I wonder if there is some case where raise would/does return > >> a meaningful value somehow? My gut reaction is 'no'... but > >> this is Ruby... > > > >I am fairly certain that the return value can never be captured. At > >least I can't figure out how to do it. > > > >In this: > > > > def raise_value > > x = raise > > rescue > > x > > end > > > > p raise_value # nil > > > >I'm pretty sure that x is nil because of the thing where the parser > >sees an assignment and defines the variable. I don't think an > >assignment ever actually takes place -- as witness the fact that: > > > > x = raise || 1 > > > >also leaves x as nil. > > But try: > > x = raise rescue nil || 1 > > Of course this is a trivial example, but the point is that raise can > in fact have a value. > def x fail "Exception" end x = return x() rescue nil Just muddying the waters. > > -- > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/