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:
commit
8887449354
1 changed files with 6 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue