Created
June 8, 2011 08:24
-
-
Save abyx/1014031 to your computer and use it in GitHub Desktop.
Fix SortedSet to ensure objects comparable with <=>
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
From 9c168445300c6fda62173d37fbbbffa1a2136e03 Mon Sep 17 00:00:00 2001 | |
From: Aviv Ben-Yosef <aviv.by@gmail.com> | |
Date: Wed, 8 Jun 2011 11:10:11 +0300 | |
Subject: [PATCH] Fix SortedSet to ensure objects comparable with <=> | |
Fixes 2 failing specs for SortedSet: | |
- SortedSet#add takes only values which responds <=> | |
- SortedSet#initialize takes only values which respond to <=> | |
--- | |
lib/set.rb | 1 + | |
1 files changed, 1 insertions(+), 0 deletions(-) | |
diff --git a/lib/set.rb b/lib/set.rb | |
index d110742..8f23443 100644 | |
--- a/lib/set.rb | |
+++ b/lib/set.rb | |
@@ -460,6 +460,7 @@ class SortedSet < Set | |
end | |
def add(o) | |
+ raise ArgumentError, "value must respond to <=>" unless o.respond_to?(:<=>) | |
@keys = nil | |
@hash[o] = true | |
self | |
-- | |
1.7.4.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment