Suggestion: if-comprehensions

So there’s been quite a few comments along the lines of “this only works for Options”, “this privileges Option”, and “for -comprehensions are more general, this is only a special case”.

Options are special, they should be special, and they are a case worth specializing for:

  1. They are how we deal with null.
  2. 0..1 is different in kind not degree from 0..N, so for comprehensions are not more general, they are different.

Options are pervasive in Scala, yet their usage is still cumbersome.

Adding if-comprehensions and def foo(s: String?) callable with foo(myString) and foo(myStringOpt: _?) as I suggested years ago (please ignore the elvis operator second part of that suggestion) would go a long way towards making Options in Scala more ergonomic.

And that is a goal worth pursuing.