In Raku: when I create an object with a CALL-ME method, I would like to use the < ... >
syntax for the signature instead of ( '...' )
when ...
is a Str.
In the documentation, there is an example of creating an operator, which is an ordinary Raku sub with a special syntax. This sort of sub automatically converts < ... >
into a Str.
For example, if I have
use v6.d;
class A {
has %.x;
method CALL-ME( Str:D $key ) { say %!x{ $key } }
}
my A $q .= new( :x( <one two three> Z=> 1..* ) );
$q('two');
$q<two>;
But this produces
2
Type A does not support associative indexing.
in block <unit> at test.raku line 10
has %.x;
tohas %.x handles <AT-KEY>;
means your example works. This follows logically from Liz's comment in the discussion I linked. But, based on what AJS said in that thread, I imply no warranties on the general fitness of this solution. – Boruclass Foo is Hash
. Thenew
issue can be solved withmethod new(|c) { self.Any::new(|c) }
– Someplace