- or download this
sub what_does_it_return () return classA | classH {
return rand(1) > 0.5
? bless( [], 'classA' )
: bless( {}, 'classH' );
}
- or download this
my classA | classH $x = what_does_it_return();
- or download this
$x->something()
- or download this
package classA;
sub something (classA $self) { ... }
- or download this
sub what_does_it_return () return classX {
return rand(1) > 0.5
? bless( [], 'classA' )
: bless( {}, 'classH' );
}
- or download this
my classX $x = what_does_it_return();
$x->something() # compile-time blowup, classX doesn't have the "someth
+ing" method!