lib/core/facets/hash/join.rb in facets-2.8.4 vs lib/core/facets/hash/join.rb in facets-2.9.0.pre.1
- old
+ new
@@ -1,14 +1,17 @@
class Hash
# Like Array#join but specialized to Hash.
#
+ # NOTE: Without Ruby 1.9 this would be difficult to rely on becuase
+ # hashes did not have a strict order.
+ #
# CREDIT: Mauricio Fernandez
- def join(pair_divider='', elem_divider='')
+ def join(pair_divider='', elem_divider=nil)
+ elem_divider ||= pair_divider
s = []
- each_pair { |k,v| s << "#{k}#{pair_divider}#{v}" }
+ each{ |k,v| s << "#{k}#{pair_divider}#{v}" }
s.join(elem_divider)
end
end
-