Created
March 3, 2016 17:35
-
-
Save codekitchen/071d57e418d8fb116fb5 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
require 'json' | |
module HashWithDupCheck | |
refine Hash do | |
def []=(k,v) | |
raise(ArgumentError, "key already exists: #{k.inspect}") if key?(k) | |
end | |
end | |
end | |
using HashWithDupCheck | |
puts JSON.parse(%[{"a": 5, "a": 6}]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've written this behavior out as a spec…
I'll figure out how to fix this behavior, and then add a spec to hold it in place.