Elixir style guards for js. Polymorphism for functions.

added by bpwndaddy
10/19/2015 6:29:00 PM

432 Views

This library implement Elixir style guards for javascript. An Elixir guard is like this: defmodule Geometry do def area({:rectangle, w, h}) do w * h end def area({:circle, r}) when is_number(r) do 3.14 * r * r end end Instead of having a function with if clauses inside we can define the conditions with the function. We have polymorphism for functions and methods.


0 comments