From 787969d491cc5b3dfdb0d5820cc0915d8ab075a6 Mon Sep 17 00:00:00 2001 From: NRoos Date: Mon, 18 Jan 2016 10:51:29 +0200 Subject: [PATCH] doend --- koodi.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/koodi.rb b/koodi.rb index 932f2b3..d112f3e 100644 --- a/koodi.rb +++ b/koodi.rb @@ -1 +1,13 @@ # kirjoita koodi tänne + +def avainten_summa(kartta) + ret = 0 + kartta.each do |key, value| + ret += key + end + return ret +end + + +hash = {1 => 2, 2 => 3, 5=>2} +puts avainten_summa(hash)