Created
February 13, 2013 20:36
-
-
Save kennyp/4948001 to your computer and use it in GitHub Desktop.
This file contains 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
h = Hash.new do |h,k| | |
l = h.keys.select {|i| i < k}.max | |
h[l] | |
end | |
h[1] = :foo | |
h[5] = :bar | |
h[3] # => :foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment