File tree Expand file tree Collapse file tree 5 files changed +35
-2
lines changed
Expand file tree Collapse file tree 5 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 1+ Wed Oct 10 17:31:12 2001 Jarkko Hietaniemi <jhi@alpha.hut.fi>
2+
3+ * In boolean contexts the string representation of sets
4+ is not the best possible one, reported by Dan Berger.
5+ Now the size of the set is returned in boolean contexts.
6+
7+ * Released as 1.11.
8+
19Fri Aug 3 15:42:38 2001 Jarkko Hietaniemi <jhi@alpha.hut.fi>
210
311 * 1.10: Added COPYRIGHT and LICENSE.
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ lib/Set/Scalar/Virtual.pm
1212README
1313t/basic.t
1414t/basic_overload.t
15+ t/boolean.t
1516t/compare.t
1617t/difference.t
1718t/intersection.t
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ local $^W = 1;
55
66use vars qw( $VERSION @ISA) ;
77
8- $VERSION = ' 1.10 ' ;
8+ $VERSION = ' 1.11 ' ;
99
1010@ISA = qw( Set::Scalar::Real Set::Scalar::Null Set::Scalar::Base) ;
1111
@@ -168,6 +168,13 @@ These methods have operator overloads:
168168
169169 $cmp = $s <=> $t;
170170
171+ In Boolean contexts such as
172+
173+ if ($set) { ... }
174+
175+ the size of the C<$set > is tested, so empty sets test as false,
176+ and non-empty sets as true.
177+
171178=head1 AUTHOR
172179
173180Jarkko Hietaniemi <jhi@iki.fi>
Original file line number Diff line number Diff line change @@ -32,7 +32,8 @@ use overload
3232 ' <' => \&is_proper_subset,
3333 ' >' => \&is_proper_superset,
3434 ' <=' => \&is_subset,
35- ' >=' => \&is_superset;
35+ ' >=' => \&is_superset,
36+ ' bool' => \&size;
3637
3738use constant OVERLOAD_BINARY_2ND_ARG => 1;
3839use constant OVERLOAD_BINARY_REVERSED => 2;
Original file line number Diff line number Diff line change 1+ use Set::Scalar;
2+
3+ print " 1..2\n " ;
4+
5+ my @a = qw( One Two Three) ;
6+ my @b = qw( Four Five Six) ;
7+
8+ my $ssa = Set::Scalar-> new(@a );
9+ my $ssb = Set::Scalar-> new(@b );
10+
11+ print " not " unless $ssa ;
12+ print " ok 1\n " ;
13+
14+ print " not " if $ssa -> intersection($ssb );
15+ print " ok 2\n " ;
16+
You can’t perform that action at this time.
0 commit comments