Why assign values to (_)?

In start function of phoenix.ex,

    _ = Phoenix.Template.engines()
    _ = Phoenix.Template.format_encoder("index.html")
    warn_on_missing_json_library()

why is it that the function values are assigned to (underscore) and the last function is just invoked and not assigned to anything???
Is the first two functions assigned to (underscore) to suppress warnings?

2 Likes

Yes. Dialyzer would complain about unused returns if the underscore wasn’t there.

6 Likes

Additionally to what @NobbZ said, I use it often to mark that I intentionally ignore returned value. This will indicate that I need this line only for its side effects.

4 Likes