in reply to Re: Best way to initialize hash x repetition array?
in thread Best way to initialize hash x repetition array?
Ah, thanks for that and of course! I was so focused on getting this x operation to work that I completely lost attention to other useful constructs. I really like the one with 'for'. I avoid using map where I can (personal preference)
The x operator is too bad though. The repeat operator x does repeat the array reference because as you said: The repeated expression is only evaluated once. But (0) in (0) x ... is also evaluated once, but still we get a copy of 0 for each assignment and we can get a reference to 0 for every assignment if we want too. So why can't the language detect when it is dealing with an array instead of an array reference and return a copy of eachthe 'evaluated' array expression for us too...
The last thing that I'd like to find now is something that automatically generates [0, 0] or [0, 0, 0 ...]. It would be easy to forget to change the size of the initialization list in code after changing the size of the arrays in the hash.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Best way to initialize hash x repetition array?
by BrowserUk (Patriarch) on Jun 30, 2018 at 04:28 UTC | |
by Veltro (Hermit) on Jun 30, 2018 at 07:28 UTC | |
by ikegami (Patriarch) on Jun 30, 2018 at 18:07 UTC | |
|
Re^3: Best way to initialize hash x repetition array?
by ikegami (Patriarch) on Jun 30, 2018 at 18:06 UTC |