Commit e66d86a5 authored by INOUE Yasuyuki's avatar INOUE Yasuyuki

refactor Hash generator loop

parent 5603b8d7
...@@ -29,8 +29,7 @@ class Hash ...@@ -29,8 +29,7 @@ class Hash
end end
raise ArgumentError, 'odd number of arguments for Hash' unless object.length % 2 == 0 raise ArgumentError, 'odd number of arguments for Hash' unless object.length % 2 == 0
h = Hash.new h = Hash.new
t = (0...(object.length >> 1)).map { |i| i * 2 } 0.step(object.length - 2, 2) do |i|
for i in t do
h[object[i]] = object[i + 1] h[object[i]] = object[i + 1]
end end
h 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