Skip to content

Instantly share code, notes, and snippets.

@mikelikespie
Created April 6, 2010 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikelikespie/358193 to your computer and use it in GitHub Desktop.
Save mikelikespie/358193 to your computer and use it in GitHub Desktop.
class Hash
alias :old_to_a :to_a
def safe_to_a
old_to_a.sort
end
def to_a
safe_to_a
end
def map(&blk)
safe_to_a.map(&blk)
end
def each(&blk)
safe_to_a.each(&blk)
end
def each_pair(&blk)
each(&blk)
end
end
class Set
alias :old_to_a :to_a
def safe_to_a
old_to_a.sort
end
def to_a
safe_to_a
end
def map(&blk)
safe_to_a.map(&blk)
end
def each(&blk)
safe_to_a.each(&blk)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment