我们\xe2\x80\x99 目前正在开发一个带有 cordova 和 InAppBrowser 插件的应用程序。我们尝试同时生成两个不同的 IAB 实例。一个使用 _system 浏览器,另一个使用 _blank 选项。
\n\n我们遇到的问题是,一旦我们打开 _system 浏览器的实例,我们似乎就失去了对先前浏览器的引用。因此,在 _system 浏览器关闭后,_blank IAB 上永远不会触发 close 事件。
\n\n这就是实际代码的样子。
\n\n// Opening iab main window\nvar ref = window.open(global.chat_mediador, \'_blank\',\'location=no,toolbar=yes\');\n\nvar handleEvents = function(event) {\n\n // Closing the iab window \n if (event.url.match(\'#close\')) {\n ref.close();\n }\n\n // Trigger custom event\n if (event.url.match(\'#openccard\')) {\n window.open(\'https://www.test.example.url.com?customerID=\' + event.customerId, \'_system\', \'location=yes\');\n }\n\n}\n\n// InAppBrowser events\n\n// This events are duplicated because loadstop works on android and\n// loadstart works on ios.\nref.addEventListener(\'loadstart\', handleEvents, false);\nref.addEventListener(\'loadstop\', …Run Code Online (Sandbox Code Playgroud) 我对那段代码有问题。
temp_state = @state
Run Code Online (Sandbox Code Playgroud)
我想要做的是将我的实例变量@state 的值分配给一个新的局部变量 temp_state。问题是当我做
temp_state.object_id = 70063255838500
state.object_id = 70063255838500
Run Code Online (Sandbox Code Playgroud)
当我修改 temp_state 时,我也在修改 @state。如何在不修改@state 的内容的情况下使用 temp_state?
以下是课程的重要部分:
class SearchNode
attr_accessor :state, :g, :f, :free_index
def initialize(state, parent = self)
@state = state
@g = parent == self ? 1 : parent.g
@h = calculate_h
@f = @g + @h
@valid_action = ["Move(Black)", "Move(Red)", "Jump(Black)", "Jump(Red)"]
@free_index = index_of_free
@parent = parent
end
def move_black_jump
free = @free_index
# PROBLEM NEXT LINE
temp_state = @state
if temp_state[free + …Run Code Online (Sandbox Code Playgroud)