108件ヒット
[101-108件を表示]
(0.041秒)
別のキーワード
ライブラリ
- ビルトイン (108)
キーワード
- === (12)
- clone (12)
-
define
_ singleton _ method (24) - dup (12)
-
respond
_ to? (12) -
respond
_ to _ missing? (12) -
singleton
_ method (12) -
singleton
_ methods (12)
検索結果
-
Object
# ===(other) -> bool (50.0) -
case 式で使用されるメソッドです。d:spec/control#case も参照してください。
...使用されるメソッドです。d:spec/control#case も参照してください。
このメソッドは case 式での振る舞いを考慮して、
各クラスの性質に合わせて再定義すべきです。
デフォルトでは内部で Object#== を呼び出します。
when 節の......て === を呼び出すことに注意してください。
また Enumerable#grep でも使用されます。
@param other 比較するオブジェクトです。
//emlist[][ruby]{
age = 12
# (0..2).===(12), (3..6).===(12), ... が実行される
result =
case age
when 0 .. 2
"baby"
wh......when /ruby(?!\s*on\s*rails)/i
"hit! #{arg}"
when String
"Instance of String class. But don't hit."
else
"unknown"
end
end
puts check([]) #=> unknown
puts check("mash-up in Ruby on Rails") #=> instance of String class. But not hit...
puts check("<Ruby's world>") #=> hit! <Ruby's wo...