in reply to Re: Thoughts on new 'class' OO in upcoming perl
in thread Thoughts on new 'class' OO in upcoming perl
For what it's worth, I believe this will work, even without support for :common:
class Foo { field $x :param = 0; field $y :param = 0; } sub Foo::create ( $class, %args ) { if ( $args{x} < 0 ) { return undef; } else { return $class->new( %args ); } } my $foo = Foo->create( x => $x, y => $y ) or do_some_error_handling();
Not the nicest workaround, but also not terrible.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Thoughts on new 'class' OO in upcoming perl
by cavac (Prior) on Mar 06, 2023 at 14:56 UTC | |
by tobyink (Canon) on Mar 06, 2023 at 15:11 UTC | |
by dsheroh (Monsignor) on Mar 07, 2023 at 08:38 UTC | |
by haj (Vicar) on Mar 06, 2023 at 20:07 UTC | |
by tobyink (Canon) on Mar 06, 2023 at 20:21 UTC | |
by haj (Vicar) on Mar 06, 2023 at 21:38 UTC |