+ 1
What is the output of this code?
t = {a:1, b:2, c:3, d:4} res = 0 t.each {|x, y| res += y if y%2 != 0 } puts res
2 Answers
+ 3
The output is 4
Explanation:
This code adds the odd values of dictionary t
which are 1 & 3 so res =1+3=4
+ 2
Thanks. It worked!