Stumped.. cant get element of array list

cant get list element.??

code
ArrayList colorList1 = hubitat.helper.ColorUtils.hexToRGB(customColor1)
log.debug "custom color 1 = $customColor1 , colorList1 = $colorList1"
number red1 = colorList1.get[0]
log.debug "red = $red1"

output.. any suggestions..
app:3272022-12-20 09:41:36.339 PMerrorgroovy.lang.MissingPropertyException: Exception evaluating property 'get' for java.util.ArrayList, Reason: groovy.lang.MissingPropertyException: No such property: get for class: java.lang.Integer on line 441 (method updated)

app:3272022-12-20 09:41:36.314 PMdebugcustom color 1 = #750000 , colorList1 = [117, 0, 0]

app:3272022-12-20 09:41:36.311 PMdebugconverting color #750000

Just do colorList[0] or colorList.get(0)

1 Like

thats what i am doing.. there is no variable called colorList its colorList1.. colorList would be null

OK, whatever. But you're doing:

colorList1.get[0] Use parens with get() or just the bracket notation. Not both.

1 Like

got ya parends instead of brackets.. thanks will givfe it a try.

I like to do this (with added null-safety check):

colorList1?.get(0) or colorMap1?.getAt("name")

2 Likes

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