Is there a reason form matching fn calls with _?

I have seen something like this: _ = do_some_stuff() which basically
calls a function but doesn’t really need/use the return value.
This, i think, was spotted inside Phoenix and i never actually did
like or understand it.
I don’t understand the point of the matching, when there’s really no need
of the return value. I i just simply call the function…

If you’re using dialyzer and have it warn on unmatched returns, that idiom is the way to silence the warning. You are acknowledging that you know there is a return value and you are explicitly ignoring it.

2 Likes

A, ok, didn’t thought about dialyzer - thanks!