From: Trans Date: 2007-07-20T09:16:56+09:00 Subject: Re: RCR? Added syntax for chains that possibly return nil On Jul 19, 4:34 pm, Stefan Rusterholz wrote: > Trans wrote: > > On Jul 19, 3:33 pm, Stefan Rusterholz wrote: > >> Trans wrote: > >> > what about > >> > foo = bar.baz.quuz rescue default > > >> See the answer to gabriele renzi (Simple: what if your exception is not > >> the NoMethodError you are worried > >> about? You'll never know.) > > > I think it rescues all StandardErrors. > > > T. > > Um, Yes, that's exactly the problem about it, wasn't that clear? It > rescues *all* StandardErrors. So you won't notice if something else than > your NoMethodError - which nil would raise - has happened. > Say your gets raises a BrokenPipe exception or similar since the server > you were connected disconnects you because of bad input you send. Your > will never see an exception being raised since that happens in the gets > you just rescue all standarderrors from. So a better RCR maybe it just to qualify the line rescue. NoMethodError being the more common, maybe a special rescue for that. Eg. bar.baz.quuz ||| default T.