in reply to Re^3: Mr. Ternary is greater than Mrs. If Else
in thread Mr. Ternary is greater than Mrs. If Else

okey... you got the power. well, i got no things in mind yet to mind storm with Mr. Ternary over Mrs. If Else. anyway my delimma was already solved. thanks guys. it was appreciated... i will come back to this topic very soon, if ever i find a good try over Mrs. If Else in Perl.

now, the good news is Mr. Tarnary operator can be used in multi-statements unlike to what i usually hear about it (that it can only be used in single statement only).

  • Comment on Re^4: Mr. Ternary is greater than Mrs. If Else

Replies are listed 'Best First'.
Re^5: Mr. Ternary is greater than Mrs. If Else
by blazar (Canon) on May 20, 2007 at 13:31 UTC
    now, the good news is Mr. Tarnary operator can be used in multi-statements unlike to what i usually hear about it (that it can only be used in single statement only).

    Nope: the arguments to ?: are expressions, period. But then Perl also has operators/functions/constructs that let you "interpolate" a whole block of code containing multiple statements into a single expression. Thus you have two different tools that you can use synergetically together: this is nothing new - just build something complex out of simple pieces.

    Update: (some philosophy) I've tried, along with others, to explain you that if, else, etc. on the one hand and ?: on the other one are different things with different purposes, although also with some overlapping. Now I'll try with an analogy: suppose you have both a pickup and a scooter available. Now, if you have a huge load to bring from some place to another place, you will probably use the former, but if it's a tiny package, the latter. Granted: nobody prohibits to you to also use the pickup to transport the tiny package nor to invent some smart binding that will allow you to put the huge load on the scooter. That is exactly what you're doing. There are languages in which you only have either the pickup or the scooter: in those cases you have to do it those ways. But Perl lets you decide: it lets you decide to pick up the best suited tool for any given job - and also the not best suited one, if you really insist to. That's part of its TMTOWTDIness.