unpairs#

Flatten a list of two-element arrayrefs into a key/value list.

Σύνοψη#

my @kvlist = unpairs @pairs;
my %hash   = unpairs @pairs;

Τι επιστρέφεται#

A flat list with exactly two elements per input arrayref: [0] becomes the key, [1] becomes the value. Missing elements and non-arrayref inputs pad with undef so that the result is always even-sized.

Παραδείγματα#

my @kv = unpairs [a => 1], [b => 2];   # ('a', 1, 'b', 2)
my %h  = unpairs pairs %other;         # round-trip
my @kv = unpairs sort { $a->[0] cmp $b->[0] } pairs %h;

Διαφορές από το upstream#

Fully compatible with upstream.

Δείτε επίσης#

  • pairs - the inverse direction.