0004 String_slice

String manipulation in Ruby is very advanced. With the `[]` method or its alias `slice`, it's easy to extract a complex part!

Via indexes.

0004-string_slice_1.png

Via a String.

0004-string_slice_2.png

Via a Regex.

0004-string_slice_3.png

The slice! method also deletes the selected part.

0004-string_slice_4.png

The []= method replaces the selected part.

0004-string_slice_5.png

Link to Ruby documentation for slice.

💡The method definition is slice(*args), do you recognize the splat operator used to handle the variable number of arguments?