2 ms·
Addendum: I gave this some more thought and realized that actually, even as I have the compiler implemented right now, the else clause above is redundant becaus
by brundolf 5y ago
Addendum: I gave this some more thought and realized that actually, even as I have the compiler implemented right now, the else clause above is redundant because an expressive if/else with no else defaults to nil for that case:
const z = if (x != nil) { x + 2 } // comes out to number|nil
So that's less verbose and may be acceptable as-is. You also shouldn't need to chain the syntax for multiple values:
const z = if (x != nil && y != nil && z != nil) {
x + y + z
}
There may also be room to make the () optional like Rust does, or maybe just dropping the {} would be better. I'll have to see how each affects parsing and readability