Hit a Snag! possible bug?!?

ok so what i am wanting to do is pretty simple.

I have two arrays, one called children and the other called selectedNameList

children contains the following [Home, Workshop]


selectedNameList contains [Home]

so when i run the following

I then look at the children and it still contains [Home, Workshop]

if i run identical code directly in a groovy console, the value of children is changed to [Workshop]…any ideas? headscratching!!!

what is it… are you sure it is the same case… groovy is case sensitive you make need to convert to lower case

The array is absolutely the same case. I have checked and re-checked. It just does not work in the smart app but absolutely does in a groovy console

print out what the variable it contains with starts round it… it may have a control character or something in it.

That in the first post is a copy and paste from the logging pane. I have logged both arrays to debug logging and compared. They are identical in case without any control characters.

I spent hours trying and carefully comparing. Has anyone else got this removeAll method working in ST? It just doesn’t work in multiple tests and I performed.

Do both lists contain elements of the same type? Wondering if it could look like a string but really be an object in there and you’re just seeing the toString() in the logs.

If in a SmartApp the following code doesn’t result in [bar], then we can say there’s a problem with the SmartThings Groovy:

​def list1 = ['foo', 'bar']
def list2 = ['foo']


log.debug list1​​​​​​​​​​​ // -> [bar]​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

If it does produce [bar], you might want to look more at what is in the two lists, or post more code to show how they are getting populated.


Thanks for your help…i do feel a bit sheepish now. I was convinced I got the first array by calling the object.name in my code, however you were correct that I was just calling the object when I checked after reading your post.

Cheers for that as I could not see the wood for the trees

1 Like

Yeah, one of the benefits of dynamic languages is you don’t have to litter your code with typing information… but the downside is that types still matter, and it’s not always clear what type your dealing with :slight_smile:

1 Like