Ruby 2.4.0 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Symbolクラス > =~

instance method Symbol#=~

self =~ other -> Integer | nil[permalink][rdoc]

正規表現 other とのマッチを行います。

(self.to_s =~ other と同じです。)

[PARAM] other:
比較対象のシンボルを指定します。
[RETURN]
マッチが成功すればマッチした位置のインデックスを、そうでなければ nil を返します。
p :foo =~ /foo/    # => 0
p :foobar =~ /bar/ # => 3
p :foo =~ /bar/    # => nil

[SEE_ALSO] String#=~