Functions opts - are there any guides or best practices on how to write them?

Hello,

I’ve been learning Elixir and Phoenix for some time and I really enjoy them. I noticed that a lot of functions in Phoenix use opts as a function argument. opts is a list of function options and I thing I could use this way of writing functions in my own projects. Are there any guides or best practices on how to write those kind of functions? When should I use it, best way to check if an option exist etc.

1 Like

You can start here: Keyword — Elixir v1.13.4

Additionally, if you don’t want to deal with it yourself as much: NimbleOptions — NimbleOptions v0.4.0