How to sum tuple values in Scala

1 Answer

0 votes
object MyClass {
    def main(args: Array[String]): Unit = {
        val t = (4, 9, 3.14, 8, 7)
           
        val sum = t._1 + t._2 + t._3 + t._4 + t._5

        println(sum)
    }
}
     
     
     
     
/*
run:
     
31.14
     
*/

 



answered Jun 3, 2021 by avibootz
...