diff options
author | Scott Barron <scott@elitists.net> | 2006-02-08 03:43:38 +0000 |
---|---|---|
committer | Scott Barron <scott@elitists.net> | 2006-02-08 03:43:38 +0000 |
commit | a447e82de4049e79dc1002257a1c6d6a660685d6 (patch) | |
tree | 8657f36078948663a81ca3812546b8ed4160be1e /activesupport/lib/active_support/core_ext | |
parent | 2d7309388d2e8236a260a191ffebc02a4add5931 (diff) | |
download | rails-a447e82de4049e79dc1002257a1c6d6a660685d6.tar.gz rails-a447e82de4049e79dc1002257a1c6d6a660685d6.tar.bz2 rails-a447e82de4049e79dc1002257a1c6d6a660685d6.zip |
A more aesthetically pleasing implementation and changelog entry
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3549 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/access.rb | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/access.rb b/activesupport/lib/active_support/core_ext/string/access.rb index c1503ab3e3..5d0e0c21aa 100644 --- a/activesupport/lib/active_support/core_ext/string/access.rb +++ b/activesupport/lib/active_support/core_ext/string/access.rb @@ -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
\ No newline at end of file +end |