What do you guys think of passing a hash to build_hash and map_hash?  That
way I can do this:

    hash = HashWithIndifferentAccess.new
    str.build_hash(hash) { |s| s.split(/\s*=\s*/) }

or this:

   hash = {}
   complexfunc do |a|
      # keep adding items to the existing hash
      a.build_hash(hash) { |n| [n.id, n] }
   end

Trivial patch below, happy to apply if it's thought a good idea.

    - Scott



diff --git a/vendor/plugins/hobo/hobosupport/lib/hobo_support/enumerable.rb
b/ve
index cc0f0e5..7098059 100644
--- a/vendor/plugins/hobo/hobosupport/lib/hobo_support/enumerable.rb
+++ b/vendor/plugins/hobo/hobosupport/lib/hobo_support/enumerable.rb
@@ -8,14 +8,12 @@ module Enumerable
     not_found
   end

-  def map_with_index
-    res = []
+  def map_with_index(res = [])
     each_with_index {|x, i| res << yield(x, i)}
     res
   end

-  def build_hash
-    res = {}
+  def build_hash(res = {})
     each do |x|
       pair = block_given? ? yield(x) : x
       res[pair.first] = pair.last if pair
@@ -23,8 +21,7 @@ module Enumerable
     res
   end

-  def map_hash
-    res = {}
+  def map_hash(res = {})
     each do |x|
       v = yield x
       res[x] = v

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to