From: Jason R. <ja...@ho...> - 2009-03-30 21:02:06
|
Precisely the point. But the construct will more often be abused than not if its in the style guide.. Dont get me wrong, I love rough, sharp pointy edges that the smart developer can use to do tricky things with, but thats more of a code cosmetics issue than actual functionality. I guess we all have opinions on where to make trade-offs, eh? ;-) Wilfried Schobeiri wrote: > Which is why you only use it in your view, not in your biz logic. The > goal is clean, short, and survivable. The example they have on the > manpage there is awful... I'd consider that borderline obfuscation. > > On Mar 30, 2009, at 15:47 , Jason Rexilius wrote: > >> The example they give on the man page is enlightening if you think >> about >> it from the point of view of some college kid who had java or .net >> classes and is learning PHP on the job doing maintenance on some >> legacy >> code base: >> >> <?php >> // Example usage for: Ternary Operator >> $action = (empty($_POST['action'])) ? 'default' : $_POST['action']; >> >> // The above is identical to this if/else statement >> if (empty($_POST['action'])) { >> $action = 'default'; >> } else { >> $action = $_POST['action']; >> } >> >> ?> >> >> >> While the ternary operation is shorter and more terse, the standard >> if/else method will be easier for them to follow. >> >> >> Again, its about survivable code not shortest code. In order to >> survive >> it has to live in the real world which often has people of various >> skill >> levels interacting with it over time.. >> >> But, I'm just a curmudgeon ;-) >> >> >> >> >> >> Jough Dempsey wrote: >>> On Mon, Mar 30, 2009 at 1:07 PM, Wilfried Schobeiri <ws...@de... >>>> wrote: >>>> Was hoping that http://wiki.php.net/rfc/ifsetor/s suggested "?:" >>>> would >>>> be accepted. >>> It was. You can short-circuit ternary operations in PHP 5.3: >>> >>> http://us2.php.net/ternary >>> >>> ------------------------------------------------------------------------------ >>> _______________________________________________ >>> chiPHPug-discuss mailing list >>> chi...@li... >>> https://lists.sourceforge.net/lists/listinfo/chiphpug-discuss >> ------------------------------------------------------------------------------ >> _______________________________________________ >> chiPHPug-discuss mailing list >> chi...@li... >> https://lists.sourceforge.net/lists/listinfo/chiphpug-discuss > > > ------------------------------------------------------------------------------ > _______________________________________________ > chiPHPug-discuss mailing list > chi...@li... > https://lists.sourceforge.net/lists/listinfo/chiphpug-discuss |