Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Ternary vs. Sort vs. Maxby Tux (Canon) |
on Aug 10, 2015 at 09:44 UTC ( [id://1137988]=note: print w/replies, xml ) | Need Help?? |
I personally prefer the ternary as it involves no overhead of extra scopes, loading modules and/or function calls: it is fast, obvious and clear (at least if you are acquainted with ternary syntax). Your worry about duplicating the value is only important if the implementation of ternary is such that it actually invokes the FETCH on the variable twice (in any language), which can be problematic is the value is overloaded and does magic on fetch. Calling sort could suffer the same, depending on the implementation. Enjoy, Have FUN! H.Merijn
In Section
Meditations
|
|