Hi,
Early days part 2. So I defined a Map for customer details as shown below:
scala> val customers = Map(1 -> (1, “A”, “S”), 2->(2, “P”, “S”))
_ customers: scala.collection.immutable.Map[Int,(Int, String, String)] = Map(1 -> (1,A,S), 2 -> (2,P,S))_
The following function I defined works fine.
scala> def getCust(x: Int, cust: Map[Int, (Int, String, String)]) = {
_ | println(cust.get(x)) }_
_ getCust: (x: Int, cust: Map[Int,(Int, String, String)])Unit_
_ scala> getCust(1, customers)_
_ Some((1,A,S))_
Then I try to redefine it by wanting to return a tuple from the function, I hit compile error which I tried to figure out to no avail. Any help is appreciated.
_scala> def getCust(x: Int, cust: Map[Int, (Int, String, String)]):(Int, String, String) = {_
_ | cust.get(x) }_
_<console>:12: error: type mismatch;_
_ found : Option[(Int, String, String)]_
_ required: (Int, String, String)_
_ cust.get(x) }_
_ ^_
Thanks,
Anoop