mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-27 07:33:57 +00:00
Added one more example with guards, fixed typos and identation.
This commit is contained in:
parent
231a211ef2
commit
a136cfe86a
@ -246,8 +246,8 @@ end
|
||||
Math.sum(1, 2) #=> 3
|
||||
Match.square(3) #=> 9
|
||||
|
||||
# To compile our little Math module save it as `math.ex` and use `elixirc`
|
||||
elixirc math.ex
|
||||
# To compile our simple Math module save it as `math.ex` and use `elixirc`
|
||||
# in your terminal: elixirc math.ex
|
||||
|
||||
# Inside a module we can define functions with `def` and private functions with `defp`.
|
||||
# A function defined with `def` is available to be invoked from other modules,
|
||||
@ -278,6 +278,8 @@ end
|
||||
|
||||
Geometry.area({:rectangle, 2, 3}) #=> 6
|
||||
Geometry.area({:circle, 3}) #=> 28.25999999999999801048
|
||||
Geometry.area({:circle, "not_a_number"})
|
||||
#=> ** (FunctionClauseError) no function clause matching in Geometry.area/1
|
||||
|
||||
# Due to immutability, recursion is a big part of elixir
|
||||
defmodule Recursion do
|
||||
|
Loading…
Reference in New Issue
Block a user