Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Elixir Deleting a key

kl = [a: 1, a: 2, b: 3, c: 0]
kl = Keyword.delete_first(kl, :b)
kl = Keyword.delete(kl, :a)

IO.puts(Keyword.get(kl, :a))
IO.puts(Keyword.get(kl, :b))
IO.puts(Keyword.get(kl, :c))

Elixir Inserting a key

kl = [a: 1, a: 2, b: 3]
kl_new = Keyword.put_new(kl, :c, 5)
IO.puts(Keyword.get(kl_new, :c))

Elixir Retrieve the Value

list = [a: 1, b: 2]
IO.puts(list[:a])

Elixir Get Rid of the Tuples

list_1 = [{:a, 1}, {:b, 2}]
list_2 = [a: 1, b: 2]
IO.puts(list_1 == list_2)

Elixir Length of a Tuple

IO.puts(tuple_size({:ok, "hello"}))

Elixir Length of a List

IO.puts(length([1, 2, :true, "str"]))

Elixir Using Single Quotes

IO.puts(is_list('Hello'))

Elixir Retrieve Information

IO.puts([104, 101, 108, 108, 111])

Elixir Convert a Char List to a String

IO.puts(is_list(to_char_list("hełło")))
IO.puts(is_binary(to_string ('hełło')))

Elixir Char lists

IO.puts('Hello')
IO.puts(is_list('Hello'))

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.