|
I misspelled an argument name (e.g. 'last_nane' below) and spent time trying to find the cause. The argument name that I used was misspelled and silently ignored. I know my error, but I would hope for more help. It seems like different class builder modules have 'non-strict' constructor and other modules have 'strict' constructor to catch the misspelled names.
I did some research (i.e. pre-init, :init methods), but did not find any way to implement a strict constructor for those applications need this feature.
Do anyone have a suggestions?
#----------- Sample code for this situation --------------
use strict;
use warnings;
package My_Class; {
use Object::InsideOut;
my @first_name :Field :Default('Tom')
:Std_All(first_name);
my @last_name :Field :Default('SirDefault')
:Std_All('last_name');
} #-- end of package scope.
package main;
my $obj = My_Class->new(
first_name => 'Larry',
#### last_name => 'Smith',
last_nane => 'Smith', #-- Incorrect spelling ...
);
print "1. Object field 'first_name' is: ", $obj->get_first_name(), "\n";
print "1. Object field 'last_name' is: ", $obj->get_last_name(), "\n";
print "\n**** Normal Exit **** \n";
exit;
|