PUZZLE TIME how would you implement in ruby a method that takes ["a", "b", "a", "c", "c"] and returns {"a" => 2, "b" => 1, "c" => 2} ?
@BillLaboon that's pretty pretty! but it does return an array of hashes instead of one hash... would need like [] instead and then .to_h
-
-
@Carols10cents Whoops, yeah. This actually gives you what you want: a = ["a", "b", "a", "c", "c"] a.uniq.map { |x| [x, a.count(x)] }.to_hThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.