Elixir: Module: case
In the example code above, case
compares the atom name passed to the function in the planemo
variable with the listed atom names (see interaction below). When an atom match is found, a following expression is executed, directed by the flow control operator ->
.
iex(1)> c("drop.ex")
[Drop]
iex(2)> Drop.fall_velocity(:earth,20)
19.79898987322333
In the interpreter example above, the atom named :earth
and the distance value of 20
are passed to the Drop
module’s function fall_velocity()
.