DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Returns a random key from your hash, but won't repeat until it's done every one. (I was using this to help quiz myself.)
class Hash
@keys_used = []
def random_key
@keys_used = [] if @keys_used.size == self.size
key = self.keys[rand(self.size)]
while @keys_used.include?(key)
key = self.keys[rand(self.size)]
end
@keys_used << key
return key
end
end
| w s p |
w := SystemWindow new.
s := ScrollPane new.
p := PasteUpMorph new.
p extent: 1000@1000.
s scroller addMorph: p.
w addMorph: s frame: (0@0 corner: 1@1).
w openInWorld.