Skip to content

Commit 451c4bb

Browse files
committed
Added spec for :vk subscript adverbial
I assume we will need a .vk method later as well. Will spec this later unless someone beats me to it / tells me not to do it.
1 parent f868fd3 commit 451c4bb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

S02-bits.pod

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2450,20 +2450,23 @@ appropriate adverb to the subscript.
24502450
@array[0,1,2] :kv; # returns 0, 'A', 1, 'B'
24512451
@array[0,1,2] :k; # returns 0, 1
24522452
@array[0,1,2] :v; # returns 'A', 'B'
2453+
@array[0,1,2] :vk; # returns 'A', 0, 'B', 1
24532454

24542455
%hash = (:a<A>, :b<B>);
24552456
%hash<a b c>; # returns 'A', 'B', (Any)
24562457
%hash<a b c> :p; # returns a => 'A', b => 'B'
24572458
%hash<a b c> :kv; # returns 'a', 'A', 'b', 'B'
24582459
%hash<a b c> :k; # returns 'a', 'b'
24592460
%hash<a b c> :v; # returns 'A', 'B'
2461+
%hash<a b c> :vk; # returns 'A', 'a', 'B', 'b'
24602462

24612463
These adverbial forms all weed out non-existing entries if the
24622464
adverb is true; if not, they leave them in, just as an ordinary slice would.
24632465
So:
24642466

24652467
@array[0,1,2] :!p; # returns 0 => 'A', 1 => 'B', 2 => (Any)
24662468
%hash<a b c> :!kv; # returns 'a', 'A', 'b', 'B', 'c', (Any)
2469+
%hash<a b c> :!vk; # returns 'A', 'a', 'B', 'b', (Any), 'c'
24672470

24682471
Likewise,
24692472

@@ -2534,16 +2537,20 @@ These combinations are considered legal and mean the following:
25342537
:delete :!p delete, return pairs of all keys attempted
25352538
:delete :kv delete, return key/values of actually deleted keys
25362539
:delete :!kv delete, return key/values of all keys attempted
2537-
:delete :v delete, return values of actually deleted keys
2538-
:delete :!v delete, return values of all keys attempted
25392540
:delete :k delete, return actually deleted keys
25402541
:delete :!k delete, return all keys attempted to delete
2542+
:delete :v delete, return values of actually deleted keys
2543+
:delete :!v delete, return values of all keys attempted
2544+
:delete :vk delete, return value/keys of actually deleted keys
2545+
:delete :!vk delete, return value/keys of all keys attempted
25412546
:delete :exists delete, return Bools indicating keys existed
25422547
:delete :!exists delete, return Bools indicating keys did not exist
25432548
:delete :exists :p delete, return pairs with key/True for key existed
25442549
:delete :exists :!p delete, return pairs with key/Bool whether key existed
25452550
:delete :exists :kv delete, return list with key,True for key existed
25462551
:delete :exists :!kv delete, return list with key,Bool whether key existed
2552+
:delete :exists :vk delete, return list with True,key for key existed
2553+
:delete :exists :!vk delete, return list with Bool,key whether key existed
25472554

25482555
An implementation is free to silently ignore any other combinations or
25492556
silently prefer one of the adverbs given above any other.

0 commit comments

Comments
 (0)