Last active
August 29, 2015 14:20
-
-
Save darioghilardi/bc6fecb82d2c13aa06be to your computer and use it in GitHub Desktop.
elixir_001: Immutability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Failed rebinding in pattern matching | |
[a, b, a] = [1, 2, 3] | |
# ** (MatchError) no match of right hand side value: [1, 2, 3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pin operator | |
a = 1 | |
a = 3 | |
^a = 5 | |
# ** (MatchError) no match of right hand side value: 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rebinding a variable | |
a = 1 | |
a = 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple assignment | |
a = 1 | |
b = 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Without reassignment | |
name = "john" | |
name_after_one_function = function1(name) | |
name_after_two_functions = function2(name_after_one_function) | |
name_after_three_functions = function3(name_after_two_functions) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment