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:
Scott Barron
2006-02-08 03:43:38 +00:00
parent 2d7309388d
commit a447e82de4
2 changed files with 4 additions and 3 deletions

View File

@@ -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

View File

@@ -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