Subject: | Possible convenience initializer |
Date: | Mon, 16 Jul 2012 19:53:23 +0000 |
To: | "bug-Set-Tiny [...] rt.cpan.org" <bug-Set-Tiny [...] rt.cpan.org> |
From: | "Morse, Richard E.MGH" <REMORSE [...] PARTNERS.ORG> |
Hi! I like Set::Tiny for simple set operations, but one thing that I find useful is to have a cleaner way to create a set. Mostly because having to do 'Set::Tiny->new' makes lines very long when trying to work with two or three sets.
I wrote a simple helper module which I've pasted below -- I think that it offers a nice initializer-as-a-function, which maybe you'd be interested in adding to the class...
I use it as:
if ( set($array1)->is_subset(set($array2)) )
Thanks,
Ricky
package Set::Tiny::Helper;
# Helper module to make it easier to create a set of objects for
# comparison purposes
use warnings;
use strict;
use parent qw(Exporter);
our @EXPORT_OK = qw(set);
our $VERSION = '0.01';
use Set::Tiny;
sub set {
if ( ref( $_[ 0 ] ) ne "" ) {
return Set::Tiny->new( @{ $_[ 0 ] } );
}
else {
return Set::Tiny->new(@_);
}
}
1;
__END__
The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.