From a5c8e0861fef293bdb7494edbff41f14d6b15262 Mon Sep 17 00:00:00 2001 From: knu Date: Wed, 31 Jul 2013 05:58:17 +0000 Subject: * lib/set.rb: [DOC] Add a couple of notes on Hash as storage. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/set.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'lib/set.rb') diff --git a/lib/set.rb b/lib/set.rb index d98cc0b0be..cc068f0a52 100644 --- a/lib/set.rb +++ b/lib/set.rb @@ -27,14 +27,21 @@ # This is a hybrid of Array's intuitive inter-operation facilities and # Hash's fast lookup. # -# The equality of each couple of elements is determined according to -# Object#eql? and Object#hash, since Set uses Hash as storage. -# # Set is easy to use with Enumerable objects (implementing +each+). # Most of the initializer methods and binary operators accept generic # Enumerable objects besides sets and arrays. An Enumerable object # can be converted to Set using the +to_set+ method. # +# Set uses Hash as storage, so you must note the following points: +# +# * Equality of elements is determined according to Object#eql? and +# Object#hash. +# * Set assumes that the identity of each element does not change +# while it is stored. Modifying an element of a set will render the +# set to an unreliable state. +# * When a string is to be stored, a frozen copy of the string is +# stored instead unless the original string is already frozen. +# # == Comparison # # The comparison operators <, >, <= and >= are implemented as -- cgit v1.2.3