Title: DICTIONARY never NULL ? Post by: Huy H. on May 07, 2019, 03:44:02 pm Here I go again with NULL...
I recently found a bug in our code where where are checking if a passed in parameter (happens to be a DICTIONARY) to a function is null. Turns out the dictionary can never be null. This is very odd -- is that the indented behavior? I guess this is similar behavior to ARRAY? Code
Output: Passed in Dictionary dict IS NOT NULL LET dict = NULL dict IS NOT NULL INITIALIZE dict to NULL dict IS NOT NULL Title: Re: DICTIONARY never NULL ? Post by: David H. on May 08, 2019, 10:11:06 am According to the documentation the DICTIONARY array is passed to/from functions by reference on the stack and not by value. Use the getLength() method to check if the dictionary is empty.
On the subject of DICTIONARY it would be nice to have the option to sort them into key order... Title: Re: DICTIONARY never NULL ? Post by: Reuben B. on May 09, 2019, 01:24:10 am I am surprised that "IF dict IS NULL" compiles. I would expect similar to "IF arr IS NULL" which generate a -4340 error, and that the correct test would be "IF dict.getLength() = 0" just like dynamic array case "IF arr.getlength() = 0".
Quote On the subject of DICTIONARY it would be nice to have the option to sort them into key order... Just sort the keys array. Code
Title: Re: DICTIONARY never NULL ? Post by: Sebastien F. on May 09, 2019, 12:46:25 pm Hello,
In upcoming FGL versions 3.10.18 and FGL 3.20.04 (this is not in 3.20 EAP3!), the compiler will raise the error -4340 when using a dictionary in expressions like IF dict IS NULL THEN: Code
Seb Title: Re: DICTIONARY never NULL ? Post by: David H. on May 09, 2019, 02:03:19 pm Just sort the keys array. Good point, I forgot about that one! Thanks. |