3

Given an roArray:

found = CreateObject("roArray", 0, true)
found.push("a")
found.push("b")
found.push("c")

What is the best way to check if value s = "s"?

Ronald Chu
  • 33
  • 1
  • 4

2 Answers2

6

If you are looking for something like this:

someArr.contains("s") 

There is no such thing, you have to implement it yourself:

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

Currently there are no more efficient ways of doing this.

Eugene Smoliy
  • 934
  • 4
  • 9
1

Don't use roArray - use roAssociativeArray instead:

found = {a: 1, b: 1}
found["c"] = true
if found.doesExist("s") then ...
Nas Banov
  • 28,347
  • 6
  • 48
  • 67