7. with statement

The special form with is used to chain a sequence of matches in order and finally return the result of do: if all the clauses match. However, if one of the clauses does not match, its result of the miss matched expression is immediately returned.

iex> with 1 <- 1+0,
2 <- 1+1,
do: IO.puts "all matched"
"all matched"

iex> with 1 <- 1+0,
2 <- 3+1,
do: IO.puts "all matched"
4
## since 2 <- 3+1 is not matched so the result of 3+1 is returned.

8. Writing Protocols

#Define a Protocol
A **Protocol** is a way to dispatch to a particular implementation of a function based on the type of the parameter.
The macros `defprotocol` and `defimpl` are used to define Protocols and Protocol implementations for different types in the following example.
```elixir
defprotocol Triple do
def triple(input)
end
defimpl Triple, for: Integer do
def triple(int) do
int * 3
end
end
defimpl Triple, for: List do
def triple(list) do
list ++ list ++ list
end
end
```
## Usage
Load the code into `iex` and execute
```shell
iex> Triple.triple(3)
9
Triple.triple([1, 2])
[1, 2, 1, 2,1,2]
```

9. Ternary Operator

There is no ternary operator like true ? "yes" : "no" . So, the following is suggested.