Ruby - String Operations
What will happen when the following Ruby code runs?
str = "hello".freeze str << " world"
str = "hello".freeze str << " world"
"hello" makes it immutable, so any modification attempt will raise an error.<< operator tries to append " world" to the frozen string, which is not allowed and causes a runtime error.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions