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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -