From: ara.t.howard@... Date: 2007-02-16T11:52:40+09:00 Subject: Re: How to do conditional operator? On Fri, 16 Feb 2007, joe@via.net wrote: > If an operator is just syntactic sugar for a message send, how do I > coose an operator based on an expression evaluation? > > For example: > > if a > s += "text" > else > s = "text" > end > > I should be able to write it something like this: > > s ((a)? send("+=") : send("=")) "text" > > Except the ruby compiler chokes on the syntax... > > Joe harp:~ > cat a.rb a, s = 42, 'foo' s.send( a ? '<<' : 'replace', 'bar' ) p s a, s = false, 'foo' s.send( a ? '<<' : 'replace', 'bar' ) p s harp:~ > ruby a.rb "foobar" "bar" -a -- we can deny everything, except that we have the possibility of being better. simply reflect on that. - the dalai lama