aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorClaudio B. <claudiob@users.noreply.github.com>2015-05-26 11:21:18 -0700
committerClaudio B. <claudiob@users.noreply.github.com>2015-05-26 11:21:18 -0700
commit888744935483abfd655ed8a8661de0e2725b53bc (patch)
treee7d3be8907e45763e5306f2f3213abe31757da9c /activesupport
parent79fb8f3593454d5b89d7df87632e1faaf1f5674c (diff)
parent379e07e06c86bd2ce851a5532a924d2b682302cc (diff)
downloadrails-888744935483abfd655ed8a8661de0e2725b53bc.tar.gz
rails-888744935483abfd655ed8a8661de0e2725b53bc.tar.bz2
rails-888744935483abfd655ed8a8661de0e2725b53bc.zip
Merge pull request #20297 from gouravtiwari/patch-9
Added multibyte slice! example to doc [ci skip]
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/multibyte/chars.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb
index 9b3cfd18e2..45cf6fc1ef 100644
--- a/activesupport/lib/active_support/multibyte/chars.rb
+++ b/activesupport/lib/active_support/multibyte/chars.rb
@@ -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