Method: String#split_at

Defined in:
lib/ruby/jruby_hack.rb

#split_at(n) ⇒ Array(String, String)

Split the string in two at the given position

Examples:

"abc".split_at(0)   #=> ["", "abc"]
"abc".split_at(2)   #=> ["ab", "c"]

Parameters:

  • n (Integer)

    number of characters at which to split (‘n > 0`)

Returns:



485
486
487
# File 'lib/ruby/jruby_hack.rb', line 485

def split_at(n)
  [take(n), drop(n)]
end