3 ms·
Yeah, that's just if as an expression, replacing the ?: operator. Compare to return (value >= radix) ? error.InvalidChar : value;
by majewsky 10y ago
Yeah, that's just if as an expression, replacing the ?: operator. Compare to
return (value >= radix) ? error.InvalidChar : value;
- naasking 10y agoI 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;
- drjeats 10y agoI 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;