Forum Discussion

EnTerr's avatar
EnTerr
Roku Guru
11 years ago

Is doco wrong on ifEnum.isEmpty() ?

I am confused about isEmpty() on enumerables. RTFM implies isEmpty() is the opposite of isNext():
"ifEnum" wrote:
...
IsNext() as Boolean
Returns true if there is a next element

IsEmpty() as Boolean
Returns true if there is not a next element

But the two do not stay in sync:
BrightScript Debugger> a = [1]
BrightScript Debugger> ? a.isEmpty(), a.isNext()
false true
BrightScript Debugger> ? a.next()
1
BrightScript Debugger> ? a.isEmpty(), a.isNext()
false false

Seems that (and i am hoping that) the actual meaning is: isEmpty() returns whether the object has no elements (regardless of where next pointer currently is).

Is this correct? I am asking for realz, got a list - want to check if it is empty and o.isEmpty() sounds as a better/properer way than checking o.count() = 0.
No RepliesBe the first to reply