Besides ?? !! with out an else part is just &&. -- Mark Biggar [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED]
-------------- Original message ---------------------- From: Damian Conway <[EMAIL PROTECTED]> > Mark J. Reed concluded: > > > So I prefer keeping a single construct, but perhaps the else-part > > could be optional? > > I hope not. The mandatory else-part is one of the most valuable features of > the ternary operator. It helps ensure that variables initialized with a > cascaded ternary actually do get initialized: > > $action = $name eq 'Kirk' ?? 'fight' > !! $name eq 'Spock' ?? 'think' > !! $shirt eq 'red' ?? 'die' > !! 'stand'; > > The required-ness of the else-part makes cascaded ternaries a safer, more > robust choice than if-elsif-else chains in many cases. > > Damian