0

What is the keyword to replace an object in 'Ruby'? As in Python it's "replace".

7th Nov 2020, 9:43 AM
Dhiraj Dubey
Dhiraj Dubey - avatar
2 Answers
+ 7
puts("aaa".gsub("a","b")) #bbb
7th Nov 2020, 9:59 AM
TOLUENE
TOLUENE - avatar
+ 5
"nine zero zero".gsub("zero","nine") #nine nine nine "nine zero zero".sub("zero","nine") #nine nine zero #replaces only first occuring String
7th Nov 2020, 11:50 AM
0_O-[MĂ€gĂĄr_SĂĄm_ÄkĂ _NĂŒllpÞïntĂȘr_ÈxĂ«cĂ©ptïön]~~
0_O-[MĂ€gĂĄr_SĂĄm_ÄkĂ _NĂŒllpÞïntĂȘr_ÈxĂ«cĂ©ptïön]~~ - avatar