What is the shortest expression I can use to return false for all numbers < 0 and the number itself for all numbers >= 0?
Left is what I have, right is want I want to be returned.
-3: false
-1: false
0: 0
1: 1
23: 23
Something really short like:
(!!number) <-- (doenst work)
If you want something shorter, you could do:
If
number >= 0isfalse, then&&will evaluate to the left operand (i.e.false). Otheriwse, it evaluates to the right operand (i.e. the number).