Permalink
Browse files

Tweak the documentation of as_hash()

* Consistent use of my (as required by perl5i)

* Consistent use of spacing in map blocks

* Be a little more cagey about exactly what the value will be.
  This will let us change it in the future if necessary.

* Show a real world example of use

For #172
  • Loading branch information...
1 parent fd036bc commit 8202f2c3493a9ba86f188ed38b87d712e85e8fca @schwern schwern committed Nov 23, 2011
Showing with 7 additions and 6 deletions.
  1. +7 −6 lib/perl5i.pm
View
@@ -622,17 +622,18 @@ If @array is not a multiple of the iteration (for example, @array has
=head3 as_hash
- %hash = @array->as_hash;
+ my %hash = @array->as_hash;
-This method returns an array with the original elements of @array mapped to 1.
-Its functionality is the exact same as:
+This method returns a %hash where each element of @array is a key.
+The values are all true. Its functionality is similar to:
- %hash = map{ $_ => 1 } @array;
+ my %hash = map { $_ => 1 } @array;
Example usage:
- my @array = ("a", "b", "c");
- my %hash = @array->as_hash;
+ my @array = ("a", "b", "c");
+ my %hash = @array->as_hash;
+ say q[@array contains 'a'] if $hash{"a"};
=head3 diff

0 comments on commit 8202f2c

Please sign in to comment.