April 2018
Beginner to intermediate
406 pages
9h 33m
English
The first thing to note is Elixir's concept of immutability. This means that any variables used will retain their value whenever they're passed along. This is a big difference from languages such as Ruby, where the state of any data you pass on is no longer guaranteed to retain its original value. Objects are a good example of this in Ruby.
To demonstrate this concept a little bit better (don't worry about the syntax yet; we'll get to that!), let's take a look at a code snippet in Javascript, as follows:
function upcase_name(p) { p.name = p.name.toUpperCase();}var person = { name: "Brandon" } // Name here is still 'Brandon'person // Output is { name: "Brandon" }upcase_name(person)person // Oh no! Output is now { name: ...