Method: String#at

Defined in:
lib/jun/active_support/core_ext/string/access.rb

#at(position) ⇒ Object

Returns a character at the given integer of the string. The first character would be returned for index 0, the second at index 1, and onward. If a range is given, a substring conaining the characters within the range of the given indicies is returned. If a Regex is provided, the matching substring is returned.

string = "smoki"
string.at(0)      # => "s"
string.at(1..3)   # => "mok"
string.at(-2)     # => "k"
string.at(/oki/)  # => "oki"


14
15
16
# File 'lib/jun/active_support/core_ext/string/access.rb', line 14

def at(position)
  self[position]
end