Publish to my blog (weekly)
-
- All the collections that we learned about in the previous lesson, with the exception of tuples, are enumerables.
- without producing a new value,
- iterate over a collection
- The
each/2
function does return the atom:ok
. - produce a new collection
- specify a function to produce the minimum value
- in case the enumerable is empty
- include only those elements
- filter the collection
- evaluate to
true
using the provided function.
-
-
- /2
- it (here
++
) and its arity - Tuples are similar to lists, but are stored contiguously in memory
- It is common for tuples to be used as a mechanism to return additional information from functions;
- Keyword lists
- the associative collections of Elixir.
-
- Keys are atoms.
- Keys are ordered.
- Keys do not have to be unique.
- keyword lists are most commonly used to pass options to functions.
- the “go-to” key-value store
- they allow keys of any type and are un-ordered
-
%{}
syntax: - variables are allowed as map keys:
- If a duplicate is added to a map, it will replace the former value:
- there is a special syntax for maps containing only atom keys:
- :foo =>
- :hello =>
- a special syntax you can use with atom keys:
- map.hello
- his creates a new map)
- %{map | foo: "baz"}
- If the key does not exist, a
KeyError
will be raised. - Map.put(map, :foo, "baz")
-
댓글