Previous page: Daily Crap 2009-04-09
Next page: Daily Crap 2009-04-14


Daily Crap 2009-04-13

  1. hash = Hash.new
    %w(cat dog wombat).each_with_index {|item, index|
      hash[item] = index
    }
    hash   #=> {"cat"=>0, "wombat"=>2, "dog"=>1}

    Maybe I've been doing too much functional programming, but I really don't want to write code like that any more. I could use an inject_with_index. Or a Ruby guru next door.

  2. … as superficial as that would be with a non-functional hash. ;)

Comments

Click here to view the comments on this post.