Tuple Example

scala> val no:Int = 10
no: Int = 10

scala> val result1 = if(no == 10) {
     |    // Tuple is represented by Round bracket / Parentheses
     |    (no, "good")
     | } else {
     |    (no, "bad")
     | }
result1: (Int, String) = (10,good)

scala> val result2 = if(no == 10) {
     |    // Another way to Create tuple 
     |    no -> "good"
     | } else {
     |    no -> "bad"
     | }
result2: (Int, String) = (10,good)


No comments:

Post a Comment