2 ms·
FWIW Rust does not have optionals chaining, except in the monadic sense (in which case ML and Haskell have optionals chaining). That is, in Rust you'd use Opti
by masklinn 8y ago
FWIW Rust does not have optionals chaining, except in the monadic sense (in which case ML and Haskell have optionals chaining).
That is, in Rust you'd use Option::map or Option::and_then, there is no equivalent to the `?.` and `?[]` operators, the `?` operator (or `try!` macro) is a shortcut for an "unwrapping guard".
- lalaithion 8y agoRight, but isn't `?.` just syntactic sugar on `Option::and_then`? Is this a patent on a piece of syntactic sugar, or is it a patent on the idea of chaining optional values?
- saghm 8y agoRuby does seem to have the exact thing: http://mitrev.net/ruby/2015/11/13/the-operator-in-ruby/ http://mitrev.net/ruby/2015/11/13/the-operator-in-ruby/