Ruby - Class Methods and Variables
Identify the error in this Ruby code snippet:
obj = "text" copy = obj.clone copy.freeze copy << " more" puts copy
obj = "text" copy = obj.clone copy.freeze copy << " more" puts copy
copy string is frozen by copy.freeze, so it cannot be modified.copy << " more" tries to modify the frozen string, causing a runtime error.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions