Remix.run Logo
legacynl 2 days ago

I don't really get it.. In one of the last example's he writes:

` if (node.last_child(s) is Ok(last_child))`

Is the part between the () not ultimately the same as a boolean expression? Like he wrote his own implementation of if/else syntax?

Also in the beginning he says: "An if with an else can produce a value", but isn't this just 'syntactic sugar'? I think the code that actually runs is the same as if you'd write if (value x = some_value) {value = something} else {value = something_else} ?

myhf 2 days ago | parent [-]

This concept doesn't require the Law of Excluded Middle that classical boolean values do.

legacynl 2 days ago | parent [-]

Ah alright, since I don't know what that is I will attribute it to my own lack of knowledge then.

IAmBroom 2 days ago | parent [-]

Basically, the Excluded Middle is for things neither True nor False.

legacynl 19 hours ago | parent [-]

Yeah okay I get it. The law basically states that 'not true' should be 'false' and vice versa.

I still don't get what's the use of this, or is this just a curiosity? It seems like the result is just a kind of ternary operator? Doesn't this still just compile to if(x.present) return x else y? Just with really obtuse syntax