【发布时间】:2015-06-22 06:25:45
【问题描述】:
座位安排
[
[:first, :second, :none],
[:first, :none, :second],
[:second, :second, :first],
]
我需要将此数组复制到新数组中。我尝试通过以下代码来做到这一点:
class Simulator
@@current_state
def initialize(seating_arrangement)
@@current_state = seating_arrangement.dup
end
但每当我对seating_arrangement 进行任何更改时,current_state 都会自动更改。我想单独保留current_state。我是ruby 的新手。请在这里帮助我
【问题讨论】:
标签: ruby-on-rails arrays ruby multidimensional-array