Re:Zig: a system language which prioritizes optimality, safe...
by majewsky on Monday August 29, 2016 @05:01AM
(#12380802)
Yeah, that's just if as an expression, replacing the ?: operator. Compare to
[ Parent
| on HN ]
Re:Zig: a system language which prioritizes optimality, safe...
by naasking on Monday August 29, 2016 @07:55AM
(#12381272)
I actually prefer a ternary arrangement that lets you chain arbitrary such expressions like a truth table:
return (value >= radix) ? error.InvalidChar:
(comeCondition) ? error.OtherError:
...
value;
Re:Zig: a system language which prioritizes optimality, safe...
by drjeats on Monday August 29, 2016 @12:39PM
(#12383099)
I like doing that too, but the Zig syntax doesn't prevent that kind of arrangement, just makes it a bit wider.
return if (value >= radix) error.InvalidChar else
if (comeCondition) error.OtherError else
...
value;
or maybe this, but it seems uglier to me: return if (value >= radix) error.InvalidChar
else if (comeCondition) error.OtherError
...
else value;