Skip to content

Instantly share code, notes, and snippets.

@mcmillhj mcmillhj/stack.p6
Last active May 4, 2018

Embed
What would you like to do?
Missing Block error on line 20
#!perl6
class Stack {
has Int @!store;
method push(Int:D $elem --> Nil) {
push @!store, $elem;
}
method pop(--> Int) {
die "UNDERFLOW" if self.is-empty();
pop @!store;
}
method peek(--> Int) {
@!store[* - 1];
}
method is-empty(-> Bool) { # Missing block
@!store.elems == 0;
}
}
my $s = Stack.new();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.