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

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

java - SmsManager sending message more than one -