D
David Garamond
# a large hash
h = { ... }
# 1. this is inefficient
first_key, first_value = h.keys[0], h.values[0]
# also, #1 is not thread-safe right?
# is there a #pairs method which returns [[k1,v1], [k2,v2], ...} or
# something similar?
# 2. will this be compatible with future ruby?
h.each_pair {|k,v| first_key, first_value = k, v; break}
h = { ... }
# 1. this is inefficient
first_key, first_value = h.keys[0], h.values[0]
# also, #1 is not thread-safe right?
# is there a #pairs method which returns [[k1,v1], [k2,v2], ...} or
# something similar?
# 2. will this be compatible with future ruby?
h.each_pair {|k,v| first_key, first_value = k, v; break}