mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
A more aesthetically pleasing implementation and changelog entry
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3549 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Make String#last return the string instead of nil when it is shorter than the limit [Scott Barron].
|
||||
|
||||
* Added delegation support to Module that allows multiple delegations at once (unlike Forwardable in the stdlib) [DHH]. Example:
|
||||
|
||||
class Account < ActiveRecord::Base
|
||||
|
||||
@@ -50,10 +50,9 @@ module ActiveSupport #:nodoc:
|
||||
# "hello".last(2) # => "lo"
|
||||
# "hello".last(10) # => "hello"
|
||||
def last(limit = 1)
|
||||
return self if self.length < limit
|
||||
self[(-limit)..-1]
|
||||
self[(-limit)..-1] || self
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user