るりまサーチ (Ruby 2.2.0)

最速Rubyリファレンスマニュアル検索!
2件ヒット [1-2件を表示] (0.053秒)
トップページ > ライブラリ:ビルトイン[x] > バージョン:2.2.0[x] > クエリ:String[x] > クエリ:Regexp[x] > クラス:Object[x]

別のキーワード

  1. string []=
  2. string slice!
  3. string slice
  4. string []
  5. string gsub

キーワード

検索結果

Object#===(other) -> bool (82.0)

case 式で使用されるメソッドです。d:spec/control#case も参照してください。

...ドは case 式での振る舞いを考慮して、
各クラスの性質に合わせて再定義すべきです。

デフォルトでは内部で Object#== を呼び出します。

when 節の式をレシーバーとして === を呼び出すことに注意してください。

また Enumerable...
...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 world>
//}

@see Object#==, Range#===, Module#===, Regexp#===, Enumerable#grep...

Object#=~(other) -> nil (46.0)

右辺に正規表現オブジェクトを置いた正規表現マッチ obj =~ /RE/ をサポートするためのメソッドです。常に nil を返します。

右辺に正規表現オブジェクトを置いた正規表現マッチ obj =~ /RE/
をサポートするためのメソッドです。常に nil を返します。

このメソッドは Ruby 2.6 から deprecated です。

この定義により、=~ が再定義されたオブジェクトでは正常にマッチを行い、
それ以外のものは nil を返すようになります。


@param other 任意のオブジェクトです。結果に影響しません。

//emlist[例][ruby]{
obj = 'regexp'
p(obj =~ /re/) #=> 0

obj = nil
p(obj =~ /re/) #=> nil
//}
...