Skip to content

Commit

Permalink
Make :delete give a better error message if not supported on the object
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Oct 5, 2013
1 parent 9f94b8c commit 11bada4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/core/Any.pm
Expand Up @@ -21,8 +21,18 @@ my class Any { # declared in BOOTSTRAP
once DEPRECATED("Method 'Any.delete'", "the :delete adverb");
Nil;
}
method delete_key(Any:U: $key) { Nil }
method delete_pos(Any:U: $pos) { Nil }
proto method delete_key(|) { * }
multi method delete_key(Any:U: $key) { Nil }
multi method delete_key(Any:D: $key) {
fail "Can not remove values from a {self.^name}";
}

proto method delete_pos(|) { * }
multi method delete_pos(Any:U: $pos) { Nil }
multi method delete_pos(Any:D: $pos) {
fail "Can not remove elements from a {self.^name}";
}

method list() {
nqp::p6list(
self.DEFINITE ?? nqp::list(self) !! nqp::list(), List, Mu
Expand Down

0 comments on commit 11bada4

Please sign in to comment.