Chris Dutton wrote:
> .... and this just jumped out at me:
> 
> class Foo {
>     private string|int bar;
>     static create(string|int newBar) {
>         bar = newBar;
>     }
> }
> 
> In other words, as I understand it, you can type the variable bar as 
> either an int or a string.
> 
> Aside from simply, "my $bar;", will we be able to repeat this behavior 
> in Perl6 programs?

Well, I'm still hopeful Larry will approve superpositions. In which case,
since types in Perl 6 are first-class, you would be able to write
the same thing something like:


        class Foo {
                attr any(str,int) $bar;

                method SETUP(any(str,int) $newBar) {
                    $bar = $newBar;
                }
        }

Damian

Reply via email to