On Tuesday, 4 September 2018 at 12:27:47 UTC, nkm1 wrote:
I also had this problem recently. I think aa.require() should
allow to add immutables (feature request). Anyway, my
workaround was along the lines of:
final class AA(Key, Value)
{
Value[] _storage;
size_t[Key] _aa;
void opI
On Tuesday, 4 September 2018 at 11:25:15 UTC, Alex wrote:
On Tuesday, 4 September 2018 at 10:30:24 UTC, Timoses wrote:
However, of course this also fails because randomly assigning
the array elements will overwrite it. So the associative array
seems like the better idea. However, not being ab
On Tuesday, 4 September 2018 at 10:30:24 UTC, Timoses wrote:
However, of course this also fails because randomly assigning
the array elements will overwrite it. So the associative array
seems like the better idea. However, not being able to
INITIALIZE an assoc array element disallows its usag
On Thursday, 6 October 2016 at 02:09:44 UTC, Adam D. Ruppe wrote:
On Thursday, 6 October 2016 at 01:23:35 UTC, Patric Dexheimer
wrote:
Why?
Because you'd be overwriting that immutable member. Structs
just put structure around their contents, but it doesn't change
their nature. That struct is
On Thursday, 6 October 2016 at 03:48:22 UTC, Mike Parker wrote:
On Thursday, 6 October 2016 at 03:05:18 UTC, Patric Dexheimer
wrote:
[...]
There's a difference between initialization and assignment.
[...]
On Thursday, 6 October 2016 at 03:48:22 UTC, Mike Parker wrote:
On Thursday, 6 Octobe
On Thursday, 6 October 2016 at 03:05:18 UTC, Patric Dexheimer
wrote:
But why i´m overwriting the struct if its the first time i´m
putting it there? (like on the array).
There's a difference between initialization and assignment.
```
// Given this structure
struct MyStruct { int x; }
// Both
On Thursday, 6 October 2016 at 03:05:18 UTC, Patric Dexheimer
wrote:
But why i´m overwriting the struct if its the first time i´m
putting it there? (like on the array).
The compiler doesn't know it is the first time (it doesn't follow
the data from creation, it just looks at that individual li
On Thursday, 6 October 2016 at 02:09:44 UTC, Adam D. Ruppe wrote:
On Thursday, 6 October 2016 at 01:23:35 UTC, Patric Dexheimer
wrote:
Why?
Because you'd be overwriting that immutable member. Structs
just put structure around their contents, but it doesn't change
their nature. That struct is
On Thursday, 6 October 2016 at 01:23:35 UTC, Patric Dexheimer
wrote:
Why?
Because you'd be overwriting that immutable member. Structs just
put structure around their contents, but it doesn't change their
nature. That struct is no different than if you wrote `immutable
size_t` as the value -
struct Test{
immutable size_t id;
}
Test[string] dict;
Test[] array;
void main(){
array~=Test(1);//work
dict["teste"] = Test(1); //fail ??
}
"Error: cannot modify struct dict["teste"] Test with immutable
members"
Why?
10 matches
Mail list logo