Dominic Mitchell <[EMAIL PROTECTED]> writes: > Piers Cawley <[EMAIL PROTECTED]> writes: > >> You're still wrong in the oneline case: >> >> if ($foo) { do_foo_stuff() } >> else { do_other_stuff() } > > Are you sure it isn't: > > $foo ? do_foo_stuff() : do_other_stuff();
What? The ternary operator in a void context? Shame on you. I 'prefer' the '&& ||' trick in such contexts, but if/else is still better since it's easy to add a statement to a block, but you can catch yourself out with either of the other choices. > > Or perhaps (which I was shown in an interview once): > > $foo && do_foo_stuff(); > $foo || do_other_stuff(); But, but, that should be $foo && do_foo_stuff() || do_other_stuff(); > > -Dom > > -- > | Semantico: creators of major online resources | > | URL: http://www.semantico.com/ | > | Tel: +44 (1273) 722222 | > | Address: 33 Bond St., Brighton, Sussex, BN1 1RD, UK. | > > > -- Piers "It is a truth universally acknowledged that a language in possession of a rich syntax must be in need of a rewrite." -- Jane Austen?