From 71ba82a853f8e72102b2ec127e1d5e3a518c24b5 Mon Sep 17 00:00:00 2001 From: Jesper Kuutti Date: Thu, 6 Sep 2018 09:39:25 +0300 Subject: [PATCH] =?UTF-8?q?Paikalliset=20testit=20l=C3=A4pi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pino.rb | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 pino.rb diff --git a/pino.rb b/pino.rb new file mode 100644 index 0000000..03e3f02 --- /dev/null +++ b/pino.rb @@ -0,0 +1,39 @@ + +class Pino + include Enumerable + + def initialize() + @t = [] + end + + + def pop() + if @t.empty? + raise "Pino on tyhjä" + end + @t.pop + end + + def push(lisattava) + @t << lisattava + end + + + # enumerablen vaatimat + def each(&block) + @t.each(&block) + end + + def any?(&block) + @t.any?(&block) + end + + +end + + +p = Pino.new +p.push(4) +p.push(5) +puts p.pop +puts p.pop