develooper Front page | perl.perl5.porters | Postings from July 2001

if then else otherwise ...

Thread Next
Brent Dax
July 29, 2001 09:05
if then else otherwise ...
Message ID:
# This makes no sense. ?: tests a boolean value, which is either true or false.
# There is no ternary state for a boolean value. True/False, Yes/No, On/Off,
# 1/0. Are you suggesting Yes/No/Maybe? Or are you redefining True and False?

No.  He's effectively saying this:

condition ? executed-if-positive : executed-if-zero : executed-if-negative

It doesn't quite fit into simple boolean logic.  This has the potential to be useful for sorters:

@indices=sort { $ary[$a] <=> $ary[$b] ? -1 : 0 : 1 } @indices;	#sort by values of another array in
reverse order

Yes, that last example can be done with a simple $ary[$b] <=> $ary[$a], but I'm trying to show you
what this feature does and I just woke up so my brain isn't up and running yet.  :^)

# Doesn't matter. What you're asking has no counterpart in boolean logic, and
# as such would make no sense in any computer language. You may have an idea,
# but you are saying it wrong if you do.

There are plenty of things that have no counterpart in boolean logic.  Where are loops defined in
Boolean logic?

--Brent Dax

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About