このマニュアルは既にメンテナンスが終了したバージョンの Ruby を対象としています。 最新版のマニュアルへ

Ruby 3.1 リファレンスマニュアル

instance method Symbol#start_with?

start_with?(*prefixes) -> boolRuby 2.7.0 から[permalink][rdoc][edit]

self の先頭が prefixes のいずれかであるとき true を返します。

(self.to_s.start_with?と同じです。)

[PARAM] prefixes:
パターンを表す文字列または正規表現 (のリスト)

[SEE_ALSO] Symbol#end_with?

[SEE_ALSO] String#start_with?

p :hello.start_with?("hell")             #=> true
p :hello.start_with?(/H/i)               #=> true

# returns true if one of the prefixes matches.
p :hello.start_with?("heaven", "hell")   #=> true
p :hello.start_with?("heaven", "paradise") #=> false