diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-11 13:11:06 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-11 13:11:06 -0500 |
commit | ed116eda053e8cccb5dda1c4724f8609eceaa90f (patch) | |
tree | 37cf49c0c11837ed501cd86b7d25475deaf3f40d | |
parent | b2e9d33515eb858507cfab8e15eb4a9e049a433a (diff) | |
download | rails-ed116eda053e8cccb5dda1c4724f8609eceaa90f.tar.gz rails-ed116eda053e8cccb5dda1c4724f8609eceaa90f.tar.bz2 rails-ed116eda053e8cccb5dda1c4724f8609eceaa90f.zip |
added docs to String#last
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/access.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/access.rb b/activesupport/lib/active_support/core_ext/string/access.rb index baa5b84db6..76b30b4c19 100644 --- a/activesupport/lib/active_support/core_ext/string/access.rb +++ b/activesupport/lib/active_support/core_ext/string/access.rb @@ -84,6 +84,16 @@ class String end end + # Returns the last character of the string. If a limit is supplied, returns a substring + # from the end of the string until it reaches the limit value (counting backwards). If + # the given limit is greater than or equal to the string length, returns self. + # + # str = "hello" + # str.last #=> "h" + # str.last(1) #=> "h" + # str.last(2) #=> "lo" + # str.last(0) #=> "" + # str.last(6) #=> "hello" def last(limit = 1) if limit == 0 '' |