1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #20297 from gouravtiwari/patch-9

Added multibyte slice! example to doc [ci skip]
This commit is contained in:
Claudio B. 2015-05-26 11:21:18 -07:00
commit 8887449354

View file

@ -88,6 +88,12 @@ module ActiveSupport #:nodoc:
# Works like <tt>String#slice!</tt>, but returns an instance of
# Chars, or nil if the string was not modified.
#
# string = 'Welcome'
# string.mb_chars.slice!(3) # => #<ActiveSupport::Multibyte::Chars:0x000000038109b8 @wrapped_string="c">
# string # => 'Welome'
# string.mb_chars.slice!(0..3) # => #<ActiveSupport::Multibyte::Chars:0x00000002eb80a0 @wrapped_string="Welo">
# string # => 'me'
def slice!(*args)
chars(@wrapped_string.slice!(*args))
end