[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to do conditional operator?

joe

2/16/2007 2:27:00 AM

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

2 Answers

dblack

2/16/2007 2:41:00 AM

0

Ara.T.Howard

2/16/2007 2:53:00 AM

0