Commit e66d86a5 authored by INOUE Yasuyuki's avatar INOUE Yasuyuki

refactor Hash generator loop

parent 5603b8d7
......@@ -29,8 +29,7 @@ class Hash
end
raise ArgumentError, 'odd number of arguments for Hash' unless object.length % 2 == 0
h = Hash.new
t = (0...(object.length >> 1)).map { |i| i * 2 }
for i in t do
0.step(object.length - 2, 2) do |i|
h[object[i]] = object[i + 1]
end
h
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment