develooper Front page | perl.perl5.porters | Postings from February 2021

Re: Blessed objects are `isa` their reftype

Thread Previous | Thread Next
From:
Dan Book
Date:
February 16, 2021 21:17
Subject:
Re: Blessed objects are `isa` their reftype
Message ID:
CABMkAVWV2UV9ERuy9bH24vTe8a+4GPkf9PJ6srE3rgaihzJDsg@mail.gmail.com
On Tue, Feb 16, 2021 at 4:14 PM David Christensen <dpchrist@holgerdanske.com>
wrote:

> On 2021-02-16 04:09, Paul "LeoNerd" Evans wrote:
> > There is an odd asymmetry with isa when testing if an object is derived
> > from its reference type:
> >
> >    my $aref = [ 1, 2, 3 ];
> >    $aref isa ARRAY             # is false
> >
> >    my $aobj = bless [ 5, 6, 7 ], "MyArray::Class";
> >    $aobj isa MyArray::Class    # is true
> >    $aobj isa ARRAY             # is true(!)
>
>
> Please post a valid Perl program that demonstrates your point (e.g.
> Test::More, ok, TODO).
>

The 'isa' feature must be enabled and requires Perl 5.32+.

-Dan

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About