Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
norbajunior committed Mar 31, 2021
1 parent af51889 commit ba90a5d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,23 @@ Let's see this in practice:
By default our `Door` is `locked`

```elixir
iex> door = %Door{}
iex> door_locked = %Door{}
%Door{state: :locked}
```

So let's change its state to `unlocked` and `opened`

```elixir
iex> {:ok, door} = Door.transit(door, event: "unlock")
iex> {:ok, door_unlocked} = Door.transit(door_locked, event: "unlock")
{:ok, %Door{state: :unlocked}}
iex> {:ok, door} = Door.transit(door, event: "open")
iex> {:ok, door} = Door.transit(door_unlocked, event: "open")
{:ok, %Door{state: :opened}}
```

If we try to make a transition that not follow the rules, we got an error:

```elixir
iex> Door.transit(door, event: "lock")
iex> Door.transit(door_opened, event: "lock")
{:error, :not_allowed}
```

Expand Down

0 comments on commit ba90a5d

Please sign in to comment.