Empty non-null Associative Arrays should be trivial or even the default.
Rekel
paultjeadriaanse at gmail.com
Tue Aug 3 16:28:03 UTC 2021
Feel free to disregard my previous post seems valid, as I seem to
have misunderstood the meaning of AA's being null. (Wish I'd
triple checked, it was an incorrect use of ) Sorry for wasting
anyone's time...
How can all properties still be callable with a null-AA? This
surprises me.
Also a small sidequestion; how come remove is part of AA's
definition while the removal of items from dynamic lists is part
of the library instead?
---
https://tenor.com/view/justin-timberlake-jt-bad-teacher-stupid-ifeel-stupid-gif-3547095
For those interested, my range error was caused by the following
mistake;
```d
int[][int] aa;
void addElement(int element) {
aa[0] ~= element;
}
void main(string[] args) { // Works
addElement(0);
aa[0].writeln();
}
void main(string[] args) { // Does not work
aa[0].writeln();
}
```
Assumptions thus on present elements, although the first main
does not allude to its absence. In particular, why can one `~=`
when aa[0] does not exist?
Likewise, why is this valid:?
```d
int[] a;
assert(a is null); // Strange to me this works as many have said
dynamic arrays are structs.
a ~= 1;
writeln(a);
writeln([] ~ 1);
// But not writeln(null ~ 1);
```
---
Again sorry for my previous mistake. I'll be more careful in the
future.
- Paul
More information about the Digitalmars-d
mailing list