Page 2 of 2

Re: Using a value as a key in array

Posted: Wed Jan 08, 2020 11:24 pm
by FourthWorld
dunbarx wrote: Wed Jan 08, 2020 10:58 pm Jacque.

A fair point. And if one is careful, one can surely use numbers, even with field names.

But I would still do what we both have advised in the past, maybe something like “p1”?
Integer names for objects are problematic in some cases because LC allows us to refer to objects by ordinal number, creating an ambiguity about how the object is being addressed.

Array keys are always strings, even if characters in the string are numerals. We don't currently have indexed arrays in LC Script, only associative arrays, so there's no ambiguity in addressing them.

Re: Using a value as a key in array

Posted: Wed Jan 08, 2020 11:39 pm
by jacque
What Richard said. In my case, using numeric references is the cleanest way to do it. There's no danger, numeric array keys are unique references.

Re: Using a value as a key in array

Posted: Thu Jan 09, 2020 12:12 am
by dunbarx
You are both right.

I was being overly pedantic.

Craig

Re: Using a value as a key in array

Posted: Thu Jan 09, 2020 1:58 am
by jacque
dunbarx wrote: Thu Jan 09, 2020 12:12 am I was being overly pedantic.
Oh, I don't know. Maybe just overly cautious. :-)