Ruby/String/insert

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

Add a word (plus a space)

"Be careful!".insert 3, "very " # => "Be very careful!"



Inserting a String in a String

The insert method lets you insert another string at a given index in a string. 
"Be carful.".insert 6, "e"



throw the * method in

"Be careful!".insert 3, "very " * 5