From 80ecfe2270ae1add0f1f632401ecd9abf465065f Mon Sep 17 00:00:00 2001 From: Vitor Oliveira Date: Sun, 27 Dec 2020 14:07:08 -0800 Subject: [PATCH] Add StackOverflowError example --- data_structures/stacks/stack.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/data_structures/stacks/stack.rb b/data_structures/stacks/stack.rb index c2f9784..c45283d 100644 --- a/data_structures/stacks/stack.rb +++ b/data_structures/stacks/stack.rb @@ -72,3 +72,16 @@ puts stack.size puts stack.inspect # => # + +stack.push(13) +stack.push(15) +stack.push(17) +stack.push(19) +stack.push(23) +stack.push(25) +stack.push(27) +# At this point, the stack is full + +stack.push(29) +# => data_structures/stacks/stack.rb:18:in `push': StackOverflowError (StackOverflowError) +# from data_structures/stacks/stack.rb:83:in `
'