def functionThatReturnsTwoThings(): Tuple2[String,String] = { ("one", "two") // Or more verbose: // return new Tuple2("one", "two") } def test() { val result = functionThatReturnsTwoThings() val one = result._1 val two = result._2 }
Programming Tips - Scala: have a method return two things
Date: 2012nov30
Language: Scala
Q. Scala: have a method return two things
A. You can use the Tuple2 class for that. Example: