Pattern matching like you see in OCaml variants (ReasonML, F#, etc.)
match x with | 0 -> "Nothin\'" | 1 -> "One" | 2 | 3 -> "Deuce or trey!" | i when i < 10 -> "Still a single digit!" | _ -> "Big stuff!"
Elixir has something similar in guards:
def f(0), do: "Nothin\'" def f(1), do: "One" def f(x) when x == 2 or x == 3, do: "Deuce or trey!" def f(x) when x < 10, do: "Still a single digit!" def f(_x), do: "Big stuff!"
+1 for Guards.
Also I really enjoy Pipes, like
my_data |> dedupe |> reverse |> skedoodle
instead of
skedoodle(reverse(dedupe(my_data)))
I think they are even coming to JS.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Pattern matching like you see in OCaml variants (ReasonML, F#, etc.)
Elixir has something similar in guards:
+1 for Guards.
Also I really enjoy Pipes, like
instead of
I think they are even coming to JS.