Project

General

Profile

Feature #13000

Implement Set#include? with Hash#include?

Added by headius (Charles Nutter) over 4 years ago. Updated 6 months ago.

Status:
Feedback
Priority:
Normal
Target version:
-
[ruby-core:78467]
Tags:

Description

Why does Set#include? not call Hash#include?? Currently it calls Hash#[].

The protocol of Set already use Hash#include? for ==.

diff --git a/lib/set.rb b/lib/set.rb
index 43c388c..f3dbe2d 100644
--- a/lib/set.rb
+++ b/lib/set.rb
@@ -230,7 +230,7 @@ def flatten!
   #
   # See also Enumerable#include?
   def include?(o)
-    @hash[o]
+    @hash.include?(o)
   end
   alias member? include?

Also available in: Atom PDF