Bizarre List Behavior - Solved - User Error!

This simple code within an App generates a totally unexpected result.

def listStyles(){
	
	def list = []
	list.add("one")
	list.add("apple")
	log.info("list is: ${list}")

	def list2 = []
	list2.add("one")
	list2.add("apple")
	log.info("list2 is: ${list2}")

	def mylist = []
	mylist.add ["one"]
	mylist.add ["apple"]
	log.info("mylist is: ${mylist}")
		
	def thislist = []
	thislist.add ["one"]
	thislist.add ["apple"]
	log.info("thislist is: ${thislist}")
	
}

Gets this output.

thislist is: []
mylist is: []
list2 is: [one, apple]
list is: [one, apple]

The conclusion is that a list[] must be named with the word list leading the name. But I've got plenty of other driver code where that is not the case.

And in case anyone asks there are no settings or state by this name.

Any comments?

1 Like

Could it be because you are using square brackets with the add on mylist and thislist? Change them to the round brackets and It should work.

4 Likes

I'm an idiot. I stared at that a while before posting and didn't see it. Bracket blindness must be a real thing.

Thanks from your neighbor in Minnesota.

4 Likes

Can't you just walk over to his house next time you don't have to bother all of us?

:wink: :rofl:

2 Likes

If I leave now I could be there by Thanksgiving. :turkey: :beers:

4 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.