Hydrazer | is there a cons operator? or should i just use the flatten prefix? ```pl | 01:51 | |
my @arr = 1..5; | |||
say [5, |@arr]; | |||
``` | |||
02:01
melezhik34 joined
|
|||
[Coke] | m: my @a=1..5; @a.unshift: 5; dd @a | 02:06 | |
camelia | Array @a = [5, 1, 2, 3, 4, 5] | ||
[Coke] | raku gives shift/unshift/pop/push for adding/removing from the ends, splice, but your way is also fine. | 02:08 | |
Hydrazer | yeah i guess that would work too | 02:16 | |
02:21
melezhik34 left
|
|||
gfldex | m:``` | 08:36 | |
sub infix:«|<<»(\a, \e) { | |||
Proxy.new(FETCH => method { |a, |e }, | |||
STORE => method (\e) {}) | |||
but role { method sink { a.push: e } }; | |||
} | |||
my @a = 1,2,3; | |||
@a |<< 4; | |||
dd @a; | |||
my @b = @a |<< 5; | |||
dd @a, @b; | |||
``` | |||
@Hydrazer#4827 We wont stop you from defining your own operator. We are very liberal. :) | 08:37 | ||
11:02
dakkar joined
11:17
dakkar left
14:07
TempIRCLogger left
14:08
TempIRCLogger joined
15:23
[Coke] left
15:57
[Coke] joined
|