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:327 2022-12-20 09:41:36.339 PMerror groovy.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:327 2022-12-20 09:41:36.314 PMdebug custom color 1 = #750000 , colorList1 = [117, 0, 0]
app:327 2022-12-20 09:41:36.311 PMdebug converting color #750000
tomw
December 21, 2022, 2:55am
2
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
tomw
December 21, 2022, 2:56am
4
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.
tomw
December 21, 2022, 2:58am
6
I like to do this (with added null-safety check):
colorList1?.get(0) or colorMap1?.getAt("name")
2 Likes
system
Closed
December 21, 2023, 2:58am
7
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.