refactor Hash generator loop

This commit is contained in:
INOUE Yasuyuki
2014-09-18 16:07:27 +09:00
parent 5603b8d79f
commit e66d86a5fb
+1 -2
View File
@@ -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