elixir KERNEL 3 Flashcards
1
Q
to_charlist(:hello)
A
=> ‘hello’
2
Q
x = %{“data” => %{user: %{id: 1}}}
pop_in(x[“data”][:user][:id])
A
=> {1, %{“data” => %{user: %{}}}}
3
Q
trunc(-1.45)
A
=> -1
4
Q
~w(cat #{“ dog bird “})
A
=> [“cat”, “dog”, “bird”]
5
Q
body = %{“data” => %{id: 1}}
x = pop_in(body[“data”][:id])
y = pop_in(body, [“data”, :id])
x == y
A
=> true
6
Q
~w(cat #{:dog} bird)
A
=> [“cat”, “dog”, “bird”]
7
Q
tl([1, 2, 3])
A
=> [2, 3]
8
Q
send self(), “hello”
A
=> “hello”
9
Q
bit_size(<<1, 2, 3>>)
A
=> 24
10
Q
unless 1 + 2 == 3, do: “hey”
A
=> nil
11
Q
binary_part(“flashcards”, 0, 5)
A
=> “flash”
12
Q
binary_part(“hello you”, 9, -3)
A
=> “you”
13
Q
unless 1 + 2 == 3 do
“hello”
else
“good bye”
end
A
=> “good bye”
14
Q
unless 1 + 2 == 5, do: “hey”
A
=> “hey”
15
Q
match?(“h”, “h”)
A
=> true