Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

A more aesthetically pleasing implementation and changelog entry

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3549 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit a447e82de4049e79dc1002257a1c6d6a660685d6 1 parent 2d73093
Scott Barron authored
View
2  activesupport/CHANGELOG
@@ -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
5 activesupport/lib/active_support/core_ext/string/access.rb
@@ -50,10 +50,9 @@ def first(limit = 1)
# "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
Please sign in to comment.
Something went wrong with that request. Please try again.