Browse files

@a->as_hash() was not returning a hash ref in scalar context.

For #172
  • Loading branch information...
1 parent e7d26c2 commit 38f9dfbaba2ca9ecc94f200f69e468fab2ba5b2a @schwern schwern committed Nov 24, 2011
Showing with 6 additions and 6 deletions.
  1. +1 −1 Changes
  2. +2 −2 lib/perl5i/2/ARRAY.pm
  3. +3 −3 t/as_hash.t
View
2 Changes
@@ -4,7 +4,7 @@
New Features
* %hash = @array->as_hash; will turn all the values in @array to
- keys in %hash.
+ keys in %hash. [github 172]
2.9.1 Fri Nov 11 16:13:32 PST 2011
Bug Fixes
View
4 lib/perl5i/2/ARRAY.pm
@@ -45,8 +45,8 @@ method map( $code ) {
}
method as_hash{
- my @result = CORE::map{ $_ => 1 } @$self;
- return wantarray ? @result : \@result;
+ my %result = CORE::map { $_ => 1 } @$self;
+ return wantarray ? %result : \%result;
}
method grep($filter) {
View
6 t/as_hash.t
@@ -6,11 +6,11 @@ use Test::More;
note 'array to hash'; {
my @array = qw(a b c);
my %hash = @array->as_hash;
-
is_deeply \%hash, {a=>1, b=>1, c=>1};
+
@array = (4, 3, 2, 1);
- %hash = @array->as_hash;
- is_deeply \%hash, {4=>1, 3=>1, 2=>1, 1=>1};
+ my $hash = @array->as_hash;
+ is_deeply $hash, {4=>1, 3=>1, 2=>1, 1=>1};
}
done_testing;

0 comments on commit 38f9dfb

Please sign in to comment.