This commit is contained in:
Rico Sta. Cruz 2017-08-30 01:29:08 +08:00
parent e1f3df96e2
commit ea4745d026
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
1 changed files with 39 additions and 0 deletions

View File

@ -102,6 +102,45 @@ user = %{name: "Tom", age: 23}
Pattern matching works in function parameters too.
Control flow
------------
{: .-three-column}
### If
```elixir
if false do
"This will never be seen"
else
"This will"
end
```
### Cond
```elixir
cond do
1 + 1 == 3 ->
"I will never be seen"
2 * 5 == 12 ->
"Me neither"
_ ->
"But I will (this is essentially an else)"
end
```
### Errors
```elixir
try do
throw(:hello)
catch
message -> "Got #{message}."
after
IO.puts("I'm the after clause.")
end
```
## Types
### Primitives