1
給定一個roArray:如何檢查一個數組是否有效地在brightscript中包含一個值?
found = CreateObject("roArray", 0, true)
found.push("a")
found.push("b")
found.push("c")
什麼是檢查是否值s = "s"
的最佳方式?
給定一個roArray:如何檢查一個數組是否有效地在brightscript中包含一個值?
found = CreateObject("roArray", 0, true)
found.push("a")
found.push("b")
found.push("c")
什麼是檢查是否值s = "s"
的最佳方式?
不要使用roArray - 使用roAssociativeArray代替:
found = {a: 1, b: 1}
found["c"] = true
if found.doesExist("s") then ...
如果您正在尋找這樣的事情:
someArr.contains("s")
有沒有這樣的事情,你必須自己實現它:
function contains(arr as Object, value as String) as Boolean
for each entry in arr
if entry = value
return true
end if
end for
return false
end function
目前沒有更有效的方法來做到這一點。
你能加入這個聊天嗎? - http://chat.stackoverflow.com/rooms/info/125578/brightscript?tab=general –