From: Robert Klemme Date: 2004-03-16T17:19:34+09:00 Subject: Re: `#catch'ing many symbols "George Ogata" schrieb im Newsbeitrag news:874qsp7o5d.fsf@optushome.com.au... > Hello, > > I find it odd that #catch can't take more than one symbol. It doesn't > scale well if you want many symbols and makes conditional catching a > chore: > > ## catch 2 syms > catch :one do > catch :two do > stuff > end > end > > ## catch one sym and conditionally catch another > catch :x do > if condition > catch :y do > stuff > end > else > stuff > end > end > > This looks better to me: > > ## catch 2 syms > catch :one, :two do > stuff > end > > ## catch one sym and conditionally catch another > catchsyms = condition ? [:x, :y] : [:x] > catch *catchsyms do > stuff > end > > Can we get this changed? I don't think so. Problem is that catch returns the instance associated with the throw and when catching multiple symbols you can't distinguish what happened. In that case a single symbol is enough because you can use the returned element to carry information about the event: irb(main):012:0> x = catch :foo do irb(main):013:1* throw :foo, "result" irb(main):014:1> end => "result" irb(main):015:0> This is sufficient for your non conditional catch example. Conditional catch does not make sense IMHO. What do you want to achieve with that? Regards robert