Debian Codegraph @

lib/prism/polyfill/byteindex.rb

raw symbols SCIP
1 # frozen_string_literal: true
2
3 # Polyfill for String#byteindex, which didn't exist until Ruby 3.2.
4 if !("".respond_to?(:byteindex))
5 String.include(
6 Module.new {
7 def byteindex(needle, offset = 0)
8 charindex = index(needle, offset)
9 slice(0...charindex).bytesize if charindex
10 end
11 }
12 )
13 end