5 ms·
Elixir, like Erlang, is functional so there are no statements. Everything is an expression, which evaluates to some value when executed. The “return” value is j
by jkhdigital 5y ago
Elixir, like Erlang, is functional so there are no statements. Everything is an expression, which evaluates to some value when executed. The “return” value is just the value of the last expression evaluated in the function call.
- cormacrelf 5y agoIs there an equivalent of the Haskell Either monad & do-notation / Rust Result + the ? (try) operator?
- mcintyre1994 5y agoSort of, there’s a convention used throughout the standard library of returning {:ok, output} or {:err, error} or nil. That makes it really easy to compose functions/check for errors. The equivalent of do-notation would be with statements I think: https://elixirschool.com/en/lessons/basics/control-structures/#with https://elixirschool.com/en/lessons/basics/control-structure...
- cormacrelf 5y agoohhhhhhhhh, with statements do sequential . Yep. I'm on board with the original post now. Thanks!