这是我正在处理的一个脚本的一部分,该脚本肯定会返回和数组,但我希望结果在[[:a, :c].to_set,[:b,:c].to_set].to_set
中,而不是在[[:c, :b], [:c, :a]]
中。
@potentially_alive = Array.new
if (self_defended?(s))
@potentially_alive.delete_if { |pa| pa.subset?(s.to_set)}
@potentially_alive.push(s.to_set)
end
如果您当前的结果是[[:a, :c], [:b, :c]]
你想把它改成[[:a, :c].to_set, [:b, :c].to_set]
您可以进行以下操作(如果是@potentially_alive = [[:a, :c], [:b, :c]]
):
@potentially_alive.map! { |a| a.to_set }
或@potentially_alive = @potentially_alive.map { |a| a.to_set }