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

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

Thanks!
-jgilray

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 _ => {}.

4 Likes

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: