Skip to content

Commit

Permalink
Update index.md
Browse files Browse the repository at this point in the history
  • Loading branch information
DewofyourYouth authored Jun 7, 2024
1 parent c1731dc commit 2e5fbca
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions content/post/elixir-cheatsheet/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ Atom are constants. Their name is their value - and they are used similarly to e
Example use of atoms:

```elixir
tup1 = {:error, "Shay's mom"} # this is a tuple with an atom and a string in it.
tup2 = {:success, "Not Shay's mom!"}
tup1 = {:error, "The sky is falling!"} # this is a tuple with an atom and a string in it.
tup2 = {:success, "Everything is under control."}
tup3 = {:something_else, "Davie Crocket"}

defmodule HandleMessage do
Expand All @@ -86,8 +86,8 @@ IO.puts(HandleMessage.check_message tup3)
Output:

```
An error occured: 'Shay's mom' 😭
Hurray! 'Not Shay's mom!' 🎉
An error occured: 'The sky is falling!' 😭
Hurray! 'Everything is under control.' 🎉
I don't know what to do with this: 'Davie Crocket' 🤷
```

Expand Down Expand Up @@ -144,8 +144,8 @@ Key value data structure.
This is an example of a `case` statement:

```elixir
tup1 = {:error, "Shay's mom"} # this is a tuple with an atom and a string in it.
tup2 = {:success, "Not Shay's mom!"}
tup1 = {:error, "The sky is falling!"} # this is a tuple with an atom and a string in it.
tup2 = {:success, "Everything is under control."}
tup3 = {:something_else, "Davie Crocket"}

defmodule HandleMessage do
Expand All @@ -166,8 +166,8 @@ IO.puts(HandleMessage.check_message tup3)
This can also be accomplished with pattern matching and overloading:

```elixir
tup1 = {:error, "Shay's mom"}
tup2 = {:success, "Not Shay's mom!"}
tup1 = {:error, "The sky is falling!"}
tup2 = {:success, "Everything is under control."}
tup3 = {:something_else, "Davie Crocket"}

defmodule HandleMessage2 do
Expand Down

0 comments on commit 2e5fbca

Please sign in to comment.