Two samples of code for which the problem is closely related

The first problem;

      return MongoDB::Cursor.new(
        collection      => self,
        OP_REPLY        => $OP_REPLY,
        criteria        => %@criteria
      );

Generates the error; 'Default constructor for 'MongoDB::Cursor' only takes named arguments'


The second problem;

      return self.find-and-modify(
        $criteria, $projection, :$remove, :$update, :$sort,
        :$new, :$upsert
      );

Generates: 'Too many positionals passed; expected 1 to 3 arguments but got 8'



To make it work I had to resort to the following.

      my $c = MongoDB::Cursor.new(
        collection      => self,
        OP_REPLY        => $OP_REPLY,
        criteria        => %@criteria
      );

      return $c;


and for the second the same way

      my $h = self.find-and-modify(
        $criteria, $projection, :$remove, :$update, :$sort,
        :$new, :$upsert
      );

      return $h;

perl6 version 2015.09-346-g0251b52 built on MoarVM version 2015.09-74-gedc44b5

Greetings
Marcel Timmerman

Reply via email to