@mjadczak: If you can’t say how many items your tuple will have in future then I suggest you to combine struct and tuple like:
defmodule MyApp.Event do
defstruct [:your, :fields, :here]
end
defmodule MyApp.Example do
alias MyApp.Event
def sample do
{:ok, %Event{your: "", fields: 0, here: true)
end
end
I’m not sure about performance, but when you are building API and changing it from 2 tuple items (initial version) to 4 and more tuple items (in next versions) then it’s easier for someone that uses your API to have always 2 tuple items with map or struct as a second tuple item.
In your case:
alias MyApp.Example
{:ok, your, fields, _here} = Example.sample
# then in next versions:
{:ok, _here, your, fields, _something, _more} = Example.sample
do_something_with(your, fields)
As I suggest:
alias MyApp.Example
{:ok, event} = Example.sample
# then in next versions:
{:ok, event} = Example.sample
do_something_with(event.your, event.fields)






















