Stumped again, how to update state variable using a string variable as key

Spent another hour searching for how, tried various things, went down more rat holes.

Feature is a variable that contains the name of a State variable that I need to update.

state.(Feature) = "new value" doesn't work. What does?

Again, standard Groovy, nothing related to state per se. :slight_smile:

Try state[feature] or state."$feature" if you really like dot notation. (Or capital F if that's what you have, though camelCase is conventional for Groovy variable names.)

2 Likes

I was so close! state.$Feature didn't work but with the quotes it sure did! Thank you.

I'm tellin' ya guys, the syntax of this language is just too much for this old-timer. I look at some statements in sample code and my head spins. My other issue is not having any Java experience. I come from VB (limited at best), and back in the 80s, Cobol and IBM Assembler.