3 ms·
> It's pretty tricky to do that in an untyped language. If you mean dynamically typed, then Elixir has it: https://elixir-lang.org/getting-started/case-cond-a
by int_19h 4y ago
> It's pretty tricky to do that in an untyped language.
If you mean dynamically typed, then Elixir has it:
https://elixir-lang.org/getting-started/case-cond-and-if.html https://elixir-lang.org/getting-started/case-cond-and-if.htm...
- ralfj 4y agoFrom a quick scroll, that seems to be just C-style `select` with `if` guards? What I was referring to is things like `match x { Some(y) => ..., None => ... }`, where there is data that is available only in some variants of the type (like `y`). Without a type, even naming these variants becomes an interesting problem. (Not unsolvable, mind you. But not obvious either, and you lose some of the benefits that algebraic data types have in typed languages.)
- int_19h 4y agoNo, it matches on the structure of data as well as embedded values. E.g. you can match on %{foo: y} vs %{bar: y}.