Tom Says: Safe code is boring code! Why??
Previous page:
Daily Crap 2009-04-09
Next page:
Daily Crap 2009-04-14
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.
Posted Apr 13, 2009, in the evening. Updated updated Apr 13, 2009, in the evening.