Timeline for Tips for golfing in <all languages>
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 11, 2016 at 9:47 | comment | added | Erik the Outgolfer |
@MichaelKohl Katenkyo's comment (what they meant, with more detail): Worth noting that, if a == 1 && b == 0 , then both b and c will be evaluated. Here is the expression, with parens: ((a) && (b)) || (c) . a&&b 's result will be 0 in this case, so c will be evaluated, because the || gate will check for the second operand if the first one is 0 .
|
|
Jul 8, 2016 at 7:45 | comment | added | Katenkyo |
@MichaelKohl note that a&&b||c can return c when a is true iff b is false, a little edge case, but we shouldn't forget that ^^
|
|
Dec 24, 2015 at 19:49 | comment | added | Jojodmo |
Using ternary in if statements can also be very helpful if(a ? b : c)
|
|
Feb 20, 2015 at 2:41 | history | wiki removed | Doorknob | ||
Apr 5, 2012 at 6:12 | history | edited | Joey | CC BY-SA 3.0 |
added 13 characters in body
|
Apr 5, 2012 at 6:11 | comment | added | Joey |
Gaffi: VBA has Iff , although it's a function, so subject to evaluation of all arguments.
|
|
Mar 28, 2012 at 14:00 | comment | added | Gaffi | Then again, some can't use either option (VBA comes to mind), but both are still good suggestions. :-) | |
Mar 28, 2012 at 9:43 | comment | added | Michael Kohl |
Languages that don't have a ternary can use a&&b||c instead. Slightly longer, but still shorter than an if .
|
|
Mar 27, 2012 at 22:21 | history | answered | MrZander | CC BY-SA 3.0 |