2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,10 +1,9 @@
empty_set = HashSet.new #=> #HashSet<[]>
set1 = Enum.into(1..4,HashSet.new) #=> #HashSet<[2, 3, 4, 1]>
Set.size(set1) #=> 4
Set.member?(set1,3) #=> true
Set.put(set1,9) #=> #HashSet<[2, 3, 4, 1, 9]>
set2 = Enum.into([0,2,4,6],HashSet.new) #=> #HashSet<[0, 2, 6, 4]>
Set.union(set1,set2) #=> #HashSet<[0, 2, 6, 4, 3, 1]>
Set.intersection(set1,set2) #=> #HashSet<[2, 4]>
Set.difference(set1,set2) #=> #HashSet<[3, 1]>
Set.subset?(set1,set2) #=> false
defmodule User do
defstruct name: "john", age: 27
end
john = %User{} #=> %User{age: 27, name: "john"}
john.name #=> "john"
%User{age: age} = john # pattern matching
age #=> 27
meg = %User{name: "meg"} #=> %User{age: 27, name: "meg"}
is_map(meg) #=> true