class StrictNamedArguments

Checks for extra named parameters on method calls and throws X::Parameter::ExtraNamed.

SYNOPSIS

use v6;
	use StrictNamedArguments;
# Just use the trait 'strict' for methods
	class Foo { 	 # your class
	    has $.valid; # attribute, used by .new
# A regular method that expects a named argument:
		# msg => 'some_value'
		# and returns the value in upper case (in this example)
	    method shout(:$msg) is strict { $msg.uc.say; self }
# The Perl6 constructor is a regular method and can also
		# me made strict if you provide the method strictly.
		# The syntax of named parameters is a hash to be blessed.
	    method new(:$valid) is strict { self.bless(valid => $valid) }
	}
Foo.new(:not-valid).shout(:not-valid);
CATCH {
		when X::Parameter::ExtraNamed {
			note Backtrace.new.full;
			note .gist;
		} 
	}

DESCRIPTION

Module StrictNamedArguments adds the trait is strict that wraps any method and applies a check for extra named arguments. If a call to the wrapped methods does got extra named arguments the exception X::Parameter::ExtraNamed is thrown.

CREDITS

BUGS

Please file bug reports on github.

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.