On 2020-01-12 18:23, ToddAndMargo via perl6-users wrote:
On 2020-01-12 16:05, Joseph Brenner wrote:
This can be done with an explicit, named subset if you like:

   subset StrOrInt where Str | Int;

   sub do_stuff ( StrOrInt $item ) {
       say "$item is a " ~ $item.^name;
   }

Hi Joseph,

I like it.

Now to figure where to put it so it is apparent
when maintaining the code.  I will play
around with placement.

Thank you!

-T


$ p6 'subset StrOrUint where Str | uint32; my StrOrUint $x = -2.14'
Type check failed in assignment to $x; expected StrOrUint but got Rat (-2.14)
  in block <unit> at -e line 1

Reply via email to