diff --git a/core/string.rbs b/core/string.rbs index 52dfa02ef..4d90a19a2 100644 --- a/core/string.rbs +++ b/core/string.rbs @@ -897,10 +897,10 @@ class String # number #=> "9" # def =~: (Regexp regex) -> Integer? - | [T] (_MatchAgainst[self, T] object) -> T + | [T] (_MatchAgainst[T] object) -> T - interface _MatchAgainst[O, T] - def =~: (O string) -> T + interface _MatchAgainst[T] + def =~: (String string) -> T end # # Returns `true` if `object` is the same object as `self`, `false` otherwise. # - def ==: (untyped obj) -> bool + def ==: (untyped object) -> bool # # Returns `true` if `object` is the same object as `self`, `false` otherwise. # - def ===: (untyped obj) -> bool + alias === == # # Equivalent to `symbol.to_s[]`; see String#[]. # - def []: (int index) -> String? - | (int start, int length) -> String? - | (Range[Integer?] range) -> String? - | (Regexp regexp) -> String? - | (Regexp regexp, int | String capture) -> String? - | (String match_str) -> String? + def []: (int start, ?int length) -> String? + | (range[int?] range) -> String? + | (Regexp regexp, ?MatchData::capture backref) -> String? + | (String substring) -> String? # # - def intern: () -> Symbol + alias intern to_sym # # Equivalent to `sym.to_s.match?`; see String#match. # - def match?: (Regexp | string pattern, ?int pos) -> bool + def match?: (Regexp | string pattern, ?int offset) -> bool # # Equivalent to `self.to_s.succ.to_sym`: @@ -378,6 +376,20 @@ class Symbol # def next: () -> Symbol + # + # Returns a frozen string representation of `self` (not including the leading + # colon): + # + # :foo.name # => "foo" + # :foo.name.frozen? # => true + # + # Related: Symbol#to_s, Symbol#inspect. + # + def name: () -> String + # # Equivalent to `self.to_s.length`; see String#length. # @@ -394,7 +406,7 @@ class Symbol # --> # Equivalent to `self.to_s.start_with?`; see String#start_with?. # - def start_with?: (*string | Regexp prefixes) -> bool + def start_with?: (*Regexp | string prefixes) -> bool #