slice!

str.slice!(fixnum) â fixnum or nil
str.slice!(fixnum, fixnum) â new_str or nil
str.slice!(range) â new_str or nil
str.slice!(regexp) â new_str or nil
str.slice!(other_str) â new_str or nil
Instance Public methods

Deletes the specified portion from str, and returns the portion deleted.

string = "this is a string"
string.slice!(2)        #=> "i"
string.slice!(3..6)     #=> " is "
string.slice!(/s.*t/)   #=> "sa st"
string.slice!("r")      #=> "r"
string                  #=> "thing"
doc_ruby_on_rails
2015-05-15 19:15:28
Comments
Leave a Comment

Please login to continue.