Name : perl-PerlX-Maybe
| |
Version : 1.001
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : 1.1
| Date : 2015-11-20 20:22:00
|
Group : Development/Libraries/Perl
| Source RPM : perl-PerlX-Maybe-1.001-1.1.src.rpm
|
Size : 0.04 MB
| |
Packager : (none)
| |
Summary : return a pair only if they are both defined
|
Description :
Moose classes (and some other classes) distinguish between an attribute being unset and the attribute being set to undef. Supplying a constructor arguments like this:
my $bob = Person->new( name => $name, age => $age, );
Will result in the \'name\' and \'age\' attributes possibly being set to undef (if the corresponding \'$name\' and \'$age\' variables are not defined), which may violate the Person class\' type constraints.
(Note: if you are the _author_ of the class in question, you can solve this using the MooseX::UndefTolerant manpage. However, some of us are stuck using non-UndefTolerant classes written by third parties.)
To ensure that the Person constructor does not try to set a name or age at all when they are undefined, ugly looking code like this is often used:
my $bob = Person->new( defined $name ? (name => $name) : (), defined $age ? (age => $age) : (), );
or:
my $bob = Person->new( (name => $name) x!!(defined $name), (age => $age) x!!(defined $age), );
A slightly more elegant solution is the \'maybe\' function.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl/SLE_11_SP4/noarch |
Hmm ... It's impossible ;-) This RPM doesn't exist on any FTP server
Provides :
perl(PerlX::Maybe)
perl(Syntax::Feature::Maybe)
perl-PerlX-Maybe
Requires :