Skip to content

Commit

Permalink
* hash.c: added documentation for Hash about how it uses eql? and
Browse files Browse the repository at this point in the history
  hash methods for the keys.  [ruby-core:09995]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/matzruby@11554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Jan 23, 2007
1 parent 81f1cc8 commit 3d9ddf1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Tue Jan 23 10:48:17 2007 Yukihiro Matsumoto <matz@ruby-lang.org>

* hash.c: added documentation for Hash about how it uses eql? and
hash methods for the keys. [ruby-core:09995]

Wed Jan 10 00:10:23 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>

* array.c (rb_ary_replace): use ptr and len of orig instead of
Expand Down
34 changes: 33 additions & 1 deletion hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -2370,7 +2370,39 @@ env_update(VALUE env, VALUE hash)
* Hashes have a <em>default value</em> that is returned when accessing
* keys that do not exist in the hash. By default, that value is
* <code>nil</code>.
*
*
* <code>Hash</code> uses <code>key.eql?</code> to test keys for equality.
* If you need to use instances of your own classes as keys in a <code>Hash</code>,
* it is recommended that you define both the <code>eql?</code> and <code>hash</code>
* methods. The <code>hash</code> method must have the property that
* <code>a.eql?(b)</code> implies <code>a.hash == b.hash</code>.
*
* class MyClass
* attr_reader :str
* def initialize(str)
* @str = str
* end
* def eql?(o)
* o.is_a?(MyClass) && str == o.str
* end
* def hash
* @str.hash
* end
* end
*
* a = MyClass.new("some string")
* b = MyClass.new("some string")
* a.eql? b #=> true
*
* h = {}
*
* h[a] = 1
* h[a] #=> 1
* h[b] #=> 1
*
* h[b] = 2
* h[a] #=> 2
* h[b] #=> 2
*/

void
Expand Down
6 changes: 3 additions & 3 deletions version.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#define RUBY_VERSION "1.9.0"
#define RUBY_RELEASE_DATE "2007-01-10"
#define RUBY_RELEASE_DATE "2007-01-23"
#define RUBY_VERSION_CODE 190
#define RUBY_RELEASE_CODE 20070110
#define RUBY_RELEASE_CODE 20070123
#define RUBY_PATCHLEVEL 0

#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2007
#define RUBY_RELEASE_MONTH 1
#define RUBY_RELEASE_DAY 10
#define RUBY_RELEASE_DAY 23

RUBY_EXTERN const char ruby_version[];
RUBY_EXTERN const char ruby_release_date[];
Expand Down

0 comments on commit 3d9ddf1

Please sign in to comment.