3 ms·
One option is match statements. Great way to make this sort of inline assignment unnecessary
by bpicolo 8y ago
One option is match statements. Great way to make this sort of inline assignment unnecessary
- arkadiytehgraet 8y agoCould you please elaborate more on what you mean by match statements? Is it an already existing feature of Kotlin?
- bpicolo 8y agoAh, I guess `when` is literally Kotlin's equivalent of match. What I'm thinking of here is Rust's match statements, which do give you the ability to make use of those intermediary values by making use of Rust's enum type. https://doc.rust-lang.org/book/second-edition/ch06-02-match.html#matching-with-optiont https://doc.rust-lang.org/book/second-edition/ch06-02-match....
- arkadiytehgraet 8y agoI see; I agree that proper pattern matching would indeed solve that as well, as e.g. Scala does.