instance method
last
Ruby on Rails 2.2.3
Since v2.2.3 Last seen in v2.3.18Available in: v2.2.3 v2.3.18
Signature
last(limit = 1)
Returns the last character of the string or the last limit characters.
Examples:
"hello".last # => "o" "hello".last(2) # => "lo" "hello".last(10) # => "hello"
Parameters
-
limitopt = 1
Source
# File activesupport/lib/active_support/core_ext/string/access.rb, line 53
def last(limit = 1)
(mb_chars[(-limit)..-1] || self).to_s
end
Defined in activesupport/lib/active_support/core_ext/string/access.rb line 53
· View on GitHub
· Improve this page
· Find usages on GitHub