What is more idiomatic, `_ => ()` or `_ => {}`

I've seen both _ => () and _ => {} used at the end of match statements. Which is preferred (if either) and why?


I would say that the former is "produce a unit" and the latter is "do nothing", which do the same thing but express different intent.

I would normally use _ => {}.


Thanks @scottmcm, I've seen both a lot and was just curious about other's thoughts

Recently I'm using drop for it.

I agree, this one allows to later on change your mind and add something like a print statement within the curly braces :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.