Answers for "print tuple in elixir"

1

how to write tuples in elixir

iex> {:ok, "hello"}
{:ok, "hello"}
iex> tuple_size {:ok, "hello"}
2
Posted by: Guest on August-24-2021
0

read tuples elixir

message = { :ok, "To improve is to change; to be perfect is to change often.", author: "Winston Churchill" }
# use the elem function to read values from a tuple
status = elem(message, 0)
message = elem(message, 1)
author = elem(message, 2)[:author]

message = { :ok, "To improve is to change; to be perfect is to change often.", author: "Winston Churchill" }
# set the values on status, message, and author with pattern matching
{ status, message, author: author } = message
Posted by: Guest on January-15-2021

Browse Popular Code Answers by Language