added 'args_pos' function on Smart::Args
Hi, I added the new 'args_pos' function on Smarts::Args. It's very similar with 'validate_pos' function on Params::Validate.
For example, you can declare the 'add' function with 'args_pos' function.
use Smart::Args;
sub add {
args_pos my $x => 'Number', my $y => 'Number';
return $x+$y;
}
Then, call it:
say add(4, 5); # => 9
Yes, it's works!
And so, it validates argument count and types.
say add(4,5,6); # => FAIL!!
say add("JOHN", "MANJIRO"); # => FAIL!!
OK. I know the interface of Smart::Args is very strange. But very useful!
Enjoy!
Published: 2010-12-28(Tue) 22:25