class String
def last(limit = 1)
str.last(0) # => ""
str.last(2) # => "lo"
str.last(1) # => "o"
str.last # => "o"
str = "hello"
the given limit is greater than or equal to the string length, returns a copy of self.
from the end of the string until it reaches the limit value (counting backwards). If
Returns the last character of the string. If a limit is supplied, returns a substring
def last(limit = 1) self[[length - limit, 0].max, limit] || raise(ArgumentError, "negative limit") end