Skip to content

Commit

Permalink
fixed bool section in Mojo::Collection documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 25, 2014
1 parent 8886369 commit 093ec04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
8 changes: 2 additions & 6 deletions lib/Mojo/Collection.pm
@@ -1,7 +1,7 @@
package Mojo::Collection;
use Mojo::Base -strict;
use overload
bool => sub { scalar @{shift()} },
bool => sub { !!@{shift()} },
'""' => sub { shift->join("\n") },
fallback => 1;

Expand Down Expand Up @@ -142,10 +142,6 @@ L<Mojo::Collection> is an array-based container for collections.
my $collection = Mojo::Collection->new(1 .. 25);
$collection->[23] += 100;
say for @$collection;
$collection=Mojo::Collection->new();
# Empty collections are false
say "I am empty" unless $collection;
=head1 FUNCTIONS
Expand Down Expand Up @@ -320,7 +316,7 @@ L<Mojo::Collection> overloads the following operators.
my $bool = !!$collection;
Always true.
True or false, depending on if the collection is empty.
=head2 stringify
Expand Down
7 changes: 4 additions & 3 deletions t/mojo/collection.t
Expand Up @@ -166,9 +166,10 @@ eval { Mojo::Collection::missing() };
like $@, qr/^Undefined subroutine &Mojo::Collection::missing called/,
'right error';

$collection = Mojo::Collection->new();
ok !$collection, 'Empty collection is falsy';
# Boolean context
$collection = Mojo::Collection->new;
ok !$collection, 'empty collection is falsy';
$collection = Mojo::Collection->new('wat');
ok $collection, ' Non-empty collection is truthy ';
ok $collection, ' non-empty collection is truthy ';

done_testing();

0 comments on commit 093ec04

Please sign in to comment.