Usually we use tuples to hold a fixed amount of data, known up-front. So if you want to print the contents of a tuple, I would recommend doing:
def print_tuple({ foo, bar, baz }) do
IO.puts foo <> bar <> baz
end
If the tuple you want to print has a dynamic size, it is very likely you want to use a list instead. You can convert the elements of a list to a binary using many functions, for example, Enum.join/2
:
IO.puts Enum.join(list)
If you are absolutely sure you want to print the tuple contents, you can do:
IO.puts Enum.join(Tuple.to_list(tuple))
Keep in mind you can print any Elixir data structure by using IO.inspect/1
.