We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have a 2d array (array of arrays), and I want to insert a new row to it.
my @map = [[11, 12], [31,32]]; my @newrow = [21, 22]; @map.splice(1, 0, @newrow);
I want @map to look like this:
@map
[ [11, 12], [21, 22], [31, 32] ]
@map will now look like this:
[ [11, 12], 21, 22, [31, 32] ]
I tried to pass [[[[@newrow]]]] to .splice(), tried to pass $@newrow, without any difference. The only workaround I found is this:
[[[[@newrow]]]]
$@newrow
@map.splice(1, 0, 'dummy'); @map[1] = @newrow;
rakudo -v
raku -v
The text was updated successfully, but these errors were encountered:
It took a minute (longer than it should have, in retrospect) but I think I have a way to resolve this without breaking any existing splice contracts.
splice
my @a = [1, 2, 3]; @a.splice(1, 1, [2, 2]) :preserve; dd @a; # [1, [2, 2], 3
Note that :preserve is just the best I've been able to come up with so far. Suggestions welcome.
:preserve
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
The Problem
I have a 2d array (array of arrays), and I want to insert a new row to it.
Expected Behavior
I want
@map
to look like this:Actual Behavior
@map
will now look like this:I tried to pass
[[[[@newrow]]]]
to .splice(), tried to pass$@newrow
, without any difference. The only workaround I found is this:Environment
rakudo -v
orraku -v
): v2023.10The text was updated successfully, but these errors were encountered: