Ruby - String Operations
What will be the output of the following Ruby code?
text = "hello hello hello"
result = text.sub('hello', 'hi')
puts resulttext = "hello hello hello"
result = text.sub('hello', 'hi')
puts resultsub does heresub replaces only the first occurrence of 'hello' with 'hi'.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions