/ Published in: Ruby

Needed a way to randomly select an item from within a Hash
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#A. Create a Hash hash = {:key1 => "item1", :key2 => "item2", :key3 => "item3"} #B. Return a new array of all the Values from the Hash items = hash.values #C. Randomly puts items[rand(items.length)]
Comments
