谁能解释这种行为
场景一
str = "hello"
str1 = str
puts str #=> hello
puts str1 #=> hello
str1 = "hi"
puts str1 #=> hi
puts str #=> hello
这里,改变 的值str1对 的值没有影响str。
情景二
str = "hello"
str1 = str
str1.gsub! "hello", "whoa!"
puts str1 #=> whoa
puts str #=> whoa
效果不应该gsub!只有str1?为什么会发生变化str?如果str1只是持有对 的引用str,那么为什么Scenario-1中的值没有变化?