sy roAssociativeArray refcnt=4 count:12
id roArray refcnt=2 count:1
"Komag" wrote:.Count() is available for AAs now. Indexers are also available (i.e., AA[1])
Can we count AA's?
"Komag" wrote:
Does that mean they're no longer "random"? Alphabetical? How can we reasonably make use of indexers
"TheEndless" wrote:Peace and blessings be upon them, indeed! --Charlie
Best debug console update is the fact that it doesn't exit the channel when you break into it now!
"Komag" wrote:Unofficially it has been in a beta for couple of months, see viewtopic.php?f=34&t=75809&p=463321#p462756
Can we count AA's?
"TheEndless" wrote:Hmmm. What firmware would that be that you are talking about? Does not work on 6.1.5518:
Indexers are also available (i.e., AA[1])
BrightScript Debugger> a = {a:1, b:2}
BrightScript Debugger> ? a[0]
Type Mismatch. (runtime error &h18) in $LIVECOMPILE(482)
"TheEndless" wrote:"Komag" wrote:
Does that mean they're no longer "random"? Alphabetical? How can we reasonably make use of indexers
They've never been "random" as the keys are always enumerated in the same order (no idea what that order is). I have no idea how you'd use indexers... I just noticed it by accident while debugging something the other day.
"EnTerr" wrote:
Hmmm. What firmware would that be that you are talking about? Does not work on 6.1.5518:
"EnTerr" wrote:
I also have serious doubts about usefulness of what you call "indexers" but looking forward to hear more
"TheEndless" wrote:"EnTerr" wrote:
... what you call "indexers" but looking forward to hear more
... I used "indexer" in the C# sense. What would you call them?
"TheEndless" wrote:But this is also an "indexer" - A["foo"]. The use of [ ] is, as we know, the AA's bread and butter.
Count() is available for AAs now. Indexers are also available (i.e., AA[1])
>>> hash = {'a': 1, 1: True, False: [1], (1e9, 'foo'): {} }So it seems almost anything can be used as key there, also do mix&match. But not quite everything - only immutable objects are allowed: strings, numbers, tuples (but no lists), frozen-sets (but no sets or dictionaries). It can be useful but questionable due to complications (both as implementation and use).
>>> hash
{'a': 1, 1: True, (1000000000.0, 'foo'): {}, False: [1]}
>>> hash['a']
1
>>> hash[1]
True
>>> hash[1e9, 'foo']
{}
The count represents the total number of items present in the container. It is displayed for roArray, roAssociativeArray, and roList.