Skip to content

Commit

Permalink
method calls and hash/array access on Nil gives Nil.
Browse files Browse the repository at this point in the history
  • Loading branch information
timo committed Dec 29, 2013
1 parent c14a846 commit 1747273
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/core/Nil.pm
Expand Up @@ -6,6 +6,24 @@ my class Nil is Cool { # declared in BOOTSTRAP
method reify($n?) { () }
method gist() { 'Nil' }
multi method Str() { '' }
}

method at_pos($pos) {
return self
}
method at_key($pos) {
return self
}
method bind_pos($pos, $bind) {
die "Attempted to bind_pos to Nil.";
}
method bind_key($pos, $bind) {
die "Attempted to bind_key to Nil.";
}
}

Nil.^add_fallback(
-> $, $name { True },
-> $, $name {
anon sub (|) { Nil }
}
);

0 comments on commit 1747273

Please sign in to comment.