Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^5: Is "ref($class) || $class" a bad thing?

by chromatic (Archbishop)
on Jul 13, 2004 at 03:37 UTC ( [id://373834]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Is "ref($class) || $class" a bad thing?
in thread Is "ref($class) || $class" a bad thing?

#!/usr/bin/perl -w use strict; use Test::More tests => 5; package Foo; sub new { my $class = shift; return unless eval { $class->isa( __PACKAGE__ ) }; bless {}, $class; } sub is_object { 1 }; package Bar; @Bar::ISA = 'Foo'; package main; sub is_object { 0 }; my $foo = Foo->new(); isa_ok( $foo, 'Foo' ); my $bar = Bar->new(); isa_ok( $bar, 'Bar' ); ok( $foo->is_object(), '$foo is an object' ); ok( $bar->is_object(), '$bar is an object' ); my $hash = Foo::new( {} ); is( $hash, undef, 'Foo::new() should not bless a reference passed in' +);

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://373834]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-04-26 04:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found