Skip to content

Instantly share code, notes, and snippets.

@darioghilardi
Last active August 29, 2015 14:20
Show Gist options
  • Save darioghilardi/bc6fecb82d2c13aa06be to your computer and use it in GitHub Desktop.
Save darioghilardi/bc6fecb82d2c13aa06be to your computer and use it in GitHub Desktop.
elixir_001: Immutability
# Failed rebinding in pattern matching
[a, b, a] = [1, 2, 3]
# ** (MatchError) no match of right hand side value: [1, 2, 3]
# Pin operator
a = 1
a = 3
^a = 5
# ** (MatchError) no match of right hand side value: 5
# rebinding a variable
a = 1
a = 3
# Simple assignment
a = 1
b = 3
# 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