The syntax thread!

I completely sympathize, I abused it for a while before I stopped. :smiley:

That being said, IMO your code will be more readable and self-explanatory if written like so:

def get_rank(schema) do
  from(s in schema, select: max(s.rank))
  |> Repo.one()
end

def get_rank_or_default(schema) do
  (get_rank(schema) || 0)
  |> Kernel.+(1)
end

At least that’s what I would say if I was code-reviewing you. :slight_smile:

3 Likes