RetroFed Forum
Your home away from modern life.
Default argument which is the 1st one and not the only one. How?
Post Reply
AuthorMessage
salvador lemmy.world salvador@lemmy.world
Joined: 2023-10-09
Quote

In a third-party project, in the models, I've encountered functions like this:

  def changeset(model \\ %__MODULE__{}, params) do
    model
    |> cast(params, @required_fields ++ @optional_fields)
    |> validate_required(@required_fields)
  end

How can a function have a default argument which is both a) first and b) followed by a mandatory one?

What's interesting, they work properly.

1   Original
Post Reply
Back to top