I have a function like so:
def print(name:String, surname:String) { println(name + " " + surname) }
I also have a Tuple2:
val johnsmith = ("John", "Smith")
When I call print with johnsmith I get the following error:
scala> print(johnsmith)
error: not enough arguments for method print: (name: String,surname: String)Unit.
Unspecified value parameter surname.
print(johnsmith)
^
Is there some way around this? I can get this to work by making print accept a Tuple2:
def print2(t:Tuple2[String,String]) { println(t._1 + " " + t._2) }
Now I can call it either way:
scala> print2(johnsmith)
John Smith
scala> print2("john", "smith")
john smith
Is there something I'm missing?