how to write tuples in elixir
iex> {:ok, "hello"}
{:ok, "hello"}
iex> tuple_size {:ok, "hello"}
2
how to write tuples in elixir
iex> {:ok, "hello"}
{:ok, "hello"}
iex> tuple_size {:ok, "hello"}
2
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
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us