Ruby - String Operations
What will be the output of the following Ruby code?
str = "Hi" str << " there" puts str
str = "Hi" str << " there" puts str
str starts as "Hi". The << operator appends " there" to it, modifying str to "Hi there".putsputs str prints the string with a newline, but the output shown is the string content without the newline character visible.<< changes string to "Hi there" [OK]<< adds text inside original string [OK]str to remain "Hi"puts output with return value<< causes an error15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions