You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: string.rb
    path of file: ./repos/truffleruby/src/main/ruby/truffleruby/core
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

# Copyright (c) 2015, 2024 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 2.0, or
    
  def byterindex(str, finish = bytesize)
    finish = Primitive.rb_to_int(finish)
    finish += bytesize if finish < 0
    return nil if finish < 0

    finish = Primitive.min(finish, bytesize)

    if finish < bytesize && !Primitive.string_is_character_head?(encoding, self, finish)
      raise IndexError, "offset #{finish} does not land on character boundary"
    end

    if Primitive.is_a?(str, Regexp)
      Primitive.regexp_check_encoding(str, self)

      match = Truffle::RegexpOperations.search_region(str, self, 0, finish, false, true)
      Primitive.regexp_last_match_set(Primitive.caller_special_variables, match)
      return match ? Primitive.match_data_byte_begin(match, 0) : nil
    end