in reply to Re^2: Coerce or transform with Types::Param
in thread Coerce or transform with Types::Param
of is a shorthand for parameterizing a type. If you do something like this, it will fail:
if ( ArrayRef[Int]->check( \@numbers ) ) { ...; }
And you need to add some parentheses which look pretty ugly:
if ( ( ArrayRef[Int] )->check( \@numbers ) ) { ...; }
The of method look a little nicer:
if ( ArrayRef->of( Int )->check( \@numbers ) ) { ...; }
And where is a shorthand for creating a child type with an additional restriction.
|
---|
In Section
Seekers of Perl Wisdom