ruby-reference-manual:524
From: sheepman <sheepman@s...>
Date: Sat, 20 Oct 2007 13:56:08 +0900
Subject: [ruby-reference-manual:524] Range#==
こんにちは sheepman です。
Range#== を書いてみました。
Index: Range
===================================================================
--- Range (revision 2174)
+++ Range (working copy)
@@ -119,3 +119,46 @@
"c"
"e"
#@end
+
+--- ==(other) -> bool
+
+指定された other が Range クラスかそのサブクラスのインスタンスであり、
+始点と終点が == メソッドで比較して等しく、[[m:Range#exclude_end?]] が同じ場合に
+true を返します。そうでない場合に false を返します。
+
+@param other 自身と比較したいオブジェクトを指定します。
+
+ p (1..2) == (1..2) #=> true
+ p (1..2) == (1...2) #=> false
+ p (1..2) == Range.new(1.0, 2.0) #=> true
+
+--- eql?(other) -> bool
+
+指定された other が Range クラスかそのサブクラスのインスタンスであり、
+始点と終点が eql? メソッドで比較して等しく、[[m:Range#exclude_end?]] が同じ場合に
+true を返します。そうでない場合に false を返します。
+
+@param other 自身と比較したいオブジェクトを指定します。
+
+ p (1..2).eql?(1..2) #=> true
+ p (1..2).eql?(1...2) #=> false
+ p (1..2).eql?(Range.new(1.0, 2.0)) #=> false
+
+--- equal?(other) -> bool
+
+指定された other が self 自身である場合のみ真を返します。
+これは [[c:Object]] クラスで定義されたデフォルトの動作で
+す。
+
+@param other 自身と比較したいオブジェクトを指定します。
+
+ r = (1..2)
+ p r.equal?(1..2) #=> false
+ p r.equal?(r) #=> true
+
+--- hash -> Integer
+
+始点と終点のハッシュ値と [[m:Range#exclude_end?]] の値からハッシュ値を計算して整数として返します。
+
+ p (1..2).hash #=> 5646
+ p (1...2).hash #=> 16782863
--
sheepman / TAMURA Takashi
sheepman@s...
--
ML: ruby-reference-manual@m...
使い方: http://QuickML.com/
-> 524 2007-10-20 06:56 [sheepman@s... ] Range#== 529 2007-10-27 10:08 ┗[okkez000@g... ]