如何将一个数组插入一个数组?
在Perl 5中,我可以这样操作:
use Data::Dumper;
my @aoa = ( [ 'a', 'A' ], [ 'c', 'C' ] );
splice( @aoa, 1, 0, [ 'b', 'B' ] );
print Dumper \@aoa;
(在Perl 6 splice
中使替换变平坦)
答案 0 :(得分:8)
my @aoa = ([1,2],[5,6]);
my @arr = 3,4;
splice(@aoa, 1, 0, [@arr,]); # or splice(@aoa, 1, 0, [[3, 4],]);
say @aoa.perl