scala Option type difference

When you write something like Option(1, 2), the compiler first desugars this to Option.apply(1, 2), and then when it sees that the Option companion object doesn't have an apply method that takes two arguments, it automatically converts the arguments into a tuple:

scala> Option(1, 2)
res0: Option[(Int, Int)] = Some((1,2))

It would do something similar for Option(1, 2, 3), Option(1, 2, 3, 4), etc.

This is known as auto-tupling and only works for methods with a single argument. For example, the following won't compile:

This "feature" is provided for syntactic convenience, and it brings Scala a little closer (at least in a superficial way) to other functional languages where tuples and function argument lists are more unified. Lots of people hate auto-tupling, though, because these things aren't actually unified in Scala, and pretending they are can lead to confusing code and annoying error messages. If you're one of these people (I am), you can turn on the -Ywarn-adapted-args compiler flag, which gives you warnings when the compiler tries to do this: