Forum Discussion

kevman's avatar
kevman
Occasional Contributor
12 years ago

Groovy Max() of list returns strange value

Hi,

I'm using the following groovy script to find max value of a list which has 2 test case properties. But returning result is confusing.


def a= context.expand( '${#TestCase#A}' )
def b= context.expand( '${#TestCase#B}' )

def Z = [a,b]

log.info Z.max()


A and B have integers like 800,900 or 1000. But if they are '900' and '1000', then Z.max() returns 900, which looks like treated like string. (compare only first character)
So I had to add toInteger() when defining Z like, 'def Z = [a.toInteger(), b.toInteger()]', then it works. Even a and b are integer before they get into Z if I check with isInteger().

So should I assume everything will turn into a string type in list?