Hash from two arrays: Difference between revisions
Content added Content deleted
(→{{header|Ruby}}: removed custom method since it is built in nowadays) |
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: update for automated testing) |
||
Line 1,153: | Line 1,153: | ||
Using the "zipwith" meta-operator on the <tt>=></tt> pair composer: |
Using the "zipwith" meta-operator on the <tt>=></tt> pair composer: |
||
{{works with|rakudo| |
{{works with|rakudo|2018.03}} |
||
<lang perl6>my @keys = <a b c d e>; |
<lang perl6>my @keys = <a b c d e>; |
||
my @values = ^5; |
my @values = ^5; |
||
my %hash = @keys Z=> @values; |
my %hash = @keys Z=> @values; |
||
⚫ | |||
⚫ | |||
<lang perl6>my %hash; |
|||
%hash{@keys} = @values; |
%hash{@keys} = @values; |
||
⚫ | |||
⚫ | |||
%( @keys Z=> @values ); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
# If you wish to enforce equal lengths, you can use a strict hyperoperator instead: |
|||
quietly # suppress warnings about unused hash |
|||
⚫ | |||
=={{header|Phix}}== |
=={{header|Phix}}== |