Ruby: how can I copy a variable without pointing to the same object?

前端 未结 3 1215
温柔的废话
温柔的废话 2020-12-03 00:23

In Ruby, how can I copy a variable such that changes to the original don\'t affect the copy?

For example:

phrase1 = \"Hello Jim\"
phrase2 = phrase1
p         


        
3条回答
提交回复
热议问题