Search code examples
scalasetparenthesesside-effects

Why is Scala's Set.subsets() method defined as an empty-paren method?


Scala's immutable Set class has a method called subsets() that returns all the subsets of a set.

Usually empty-paren methods are reserved for methods that cause side effects, but this one doesn't seem to.

Why isn't this method defined as a parameterless method? Does it in fact cause some side effect?


Solution

  • https://github.com/scala/bug/issues/9116

    Because subsets is overloaded. There used to be a type inference issue if one overload has no parens. I don't know if that type inference issue still exists, but the parens which were added as a workaround are still there.