From 09b46c7dbea6ac2ac09ba4a41fae0bf628a775f3 Mon Sep 17 00:00:00 2001 From: Gourav Tiwari Date: Mon, 29 Jun 2015 20:20:50 +0000 Subject: Fixed slice! behavior: return nil for out-of-bound parameters --- activesupport/lib/active_support/multibyte/chars.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/multibyte') diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb index f6a2e7e949..a76692ec4b 100644 --- a/activesupport/lib/active_support/multibyte/chars.rb +++ b/activesupport/lib/active_support/multibyte/chars.rb @@ -94,7 +94,8 @@ module ActiveSupport #:nodoc: # string.mb_chars.slice!(0..3) # => # # string # => 'me' def slice!(*args) - chars(@wrapped_string.slice!(*args)) + string_sliced = @wrapped_string.slice!(*args) + string_sliced ? chars(string_sliced) : nil end # Reverses all characters in the string. -- cgit v1.2.3