Hi Klaus,
When I was studying Comp Sci (nearly 20 years ago ...), they always said that the following code was the "Wally trap":
Code: Select all
if (tMyArray is not empty) and (tMyArray[tMyKey] is not empty) then
They told us to test each part of that 'if' statement separately, in case we came across a programming language that would execute both parts, even if the first part was false.
As you say, logically the above code should be fine - but I wondered if it was officially stated anywhere that it is alright to use in LiveCode.
Ah, thanks for your second comment! So 'tMyArray[tMyKey] <> empty' won't cause problems if tMyArray is empty (it won't try and do a C-type dereference of a null pointer)?
Cheers,
Eoghan.