Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: use fields; # damnit

by Juerd (Abbot)
on Aug 21, 2004 at 12:57 UTC ( #384782=note: print w/replies, xml ) Need Help??

in reply to use fields; # damnit

My way of getting error messages when using the wrong property name is by using only the accessor methods. These are made lvalues, so they can be assigned to.

use Attribute::Property; package Dog; sub new : New; sub intelligence : Property { /^\d+\z/ } package main; my $dog = Dog->new(intelligence => 15); $dog->intelligence++; my $dog = Dog->new(inteligence => 15); # error $dog->inteligence++; # error
It saves a lot of typing (pun intended) too.

Juerd # { site => '', plp_site => '', do_not_use => 'spamtrap' }

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (12)
As of 2016-10-21 18:32 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (289 votes). Check out past polls.