Hi There,

I am not sure if my RoleType @array; is correct, or if there is a better way to declare such an array. But I find the error that is happening when there are no elements in the array confusing on the first sight. It took me a while to realize that my array was empty and therefore it "means" the class/role itself.


> perl6 -e 'role Foo {method n{...}}; class Bar does Foo {method n{"n"}}; my Foo@a = (); @a.push: Bar.new; say @a[0].n'
n

> perl6 -e 'role Foo {method n{...}}; class Bar does Foo {method n{"n"}}; my Foo@a = (); say @a[0].n'
Method 'n' must be implemented by Foo because it is required by a role
  in any compose_method_table at gen/moar/m-Metamodel.nqp line 2824
  in any apply at gen/moar/m-Metamodel.nqp line 2834
  in any compose at gen/moar/m-Metamodel.nqp line 3006
  in any make_pun at gen/moar/m-Metamodel.nqp line 1692
  in any find_method at gen/moar/m-Metamodel.nqp line 1720
  in block <unit> at -e line 1

> perl6 -e 'role Foo {method n{...}}; class Bar does Foo {method n{"n"}}; my @a = (); say @a[0].n'
No such method 'n' for invocant of type 'Any'
  in block <unit> at -e line 1

Reply via email to