Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
Source by learningwithjb.com #
 
PREVIOUS NEXT
Tagged: #read #tuples #elixir
ADD COMMENT
Topic
Name
6+3 =