scala - I am trying to compare two Tuples -
i trying write function compare tuples of similar type.
def comparetuples(tuple1: (string, string, int), tuple2: (string, string, int)): (string, string, int) = { // if tuple1.int < tuple2.int return tuple1 else tuple2. }
how access third element or int in each tuple?
thanks
to access value in tuple t
, can use t._1
, t._2
, etc.
for result in
def comparetuples(tuple1: (string, string, int), tuple2: (string, string, int)): (string, string, int) = { if (tuple1._3 < tuple2._3) tuple1 else tuple2 }
Comments
Post a Comment