diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/string')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/access.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/access.rb b/activesupport/lib/active_support/core_ext/string/access.rb index 4894193665..4f70e7f5fc 100644 --- a/activesupport/lib/active_support/core_ext/string/access.rb +++ b/activesupport/lib/active_support/core_ext/string/access.rb @@ -61,8 +61,8 @@ class String # str.from(0).to(-1) # => "hello" # str.from(1).to(-2) # => "ell" def to(position) - position = [position + length, -1].max if position < 0 - self[0, position + 1] + position += size if position < 0 + self[0, position + 1].to_s end # Returns the first character. If a limit is supplied, returns a substring |