I was normally using the DynamicComponents extension when suddenly I start to get the error "Expected a unique ID, got 'id_here'". So I had a look at the extension documentation and discovered that it was the Create function that was throwing this error, cause the code if (!COMPONENTS.containsKey(id)) { was triggering the else conditional which was throwing the error. Then I searched for the containsKey() java function and discovered that it just verifies if the hash map contains the given key.
So if my code wasn't giving the same key, why was it happening? Then I tried to change my last ID variable from number to text just because I was out of ideas, but somehow it worked. Can someone please explain me it seems that different numbers are considered the same for the containsKey() function, but different letters don't?
Here are some prints for further understanding
Getting error using number variable at the end of the id. Ps: at the end of the for each looping, I changed the value of cnt variable to 5.
Working normally using text variable at the end of the id.
Thanks for the response, but I already solved my problem. I'm asking for a greater understanding about the extension. Also, the DynamicComponents is better for me because I can set the properties of the components and identify different components of the same type from the ID.
Hmm, interesting, so using this extension the approach to set components properties is using variables, correct? It's good to know for maybe another project, but for this one I think I'll use the DynamicComponents because it's working, and it'd take a lot of time to replace all the blocks. Thanks for your help, @TIMAI2 !
yes the create block will return an object of the new created component, you need to save it to a variable (normally a local one), then use it to set its property by set block.
if you want to refer to this component later, you need to save it to a global variable, or in a dictionary.