Created
November 5, 2013 17:36
-
-
Save NateBarnes/7322941 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hash | |
alias :working_brackets :[] | |
def [] key | |
if rand(10) % 5 == 0 | |
do_evil | |
else | |
working_brackets key | |
end | |
end | |
alias :working_fetch :fetch | |
def fetch *opts | |
if rand(10) % 3 == 0 | |
do_evil | |
else | |
working_fetch *opts | |
end | |
end | |
def do_evil | |
working_fetch keys.sample | |
end | |
end | |
hsh = Hash.new | |
hsh[:one] = 1 | |
hsh[:two] = 2 | |
hsh[:three] = 3 | |
hsh[:four] = 4 | |
hsh[:five] = 5 | |
10.times do | |
puts hsh[:one] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment