scala coalesces multiple function call parameters into a Tuple — can this be disabled?

后端 未结 6 1686
闹比i
闹比i 2020-12-10 06:34

This is a troublesome violation of type safety in my project, so I\'m looking for a way to disable it. It seems that if a function takes an AnyRef (or a java.lang.Object), y

6条回答
  •  情深已故
    2020-12-10 07:10

    The compile is capable of interpreting methods without round brackets. So it takes the round brackets in the fooIt to mean Tuple. Your call is the same as:

    fooIt( ("foo","bar") )
    

    That being said, you can cause the method to exclude the call, and retrieve the value if you use some wrapper like Some(AnyRef) or Tuple1(AnyRef).

提交回复
热议问题