Hello,
With the actual version of NQE not providing direct way to initialise an Empty list
ex:
let empty_list = ]
or
empty_list = ]
A workaround for this is to construct the creation of that list and providing a value with the same data type you need
// an empty List<String>
FALLBACK =
foreach x in n""]
where x != ""
select x;
// an empty list of Numbers
FALLBACK_NUMBERS=
foreach x in i0]
where x != 0
select x;
Taking this logic further we can create a function that provides us an empty list of whatever generic type. by taking a default value of that type as an input, then comparing against that value
The below block contains the full PoC code
// an empty List<String>
FALLBACK =
foreach x in ""]
where x != ""
select x;
// an empty list of Numbers
FALLBACK_NUMBERS=
foreach x in 0]
where x != 0
select x;
// An empty list of a generic type T
emptyListT(default_val)=
foreach x in default_val]
where x != default_val
select x;
foreach a in ""]
let empty_list_of_strings = FALLBACK
let empty_list_of_numbers = FALLBACK_NUMBERS
// this provides a List<IpAddress>
let empty_list_of_ips = emptyListT(ipAddress("127.0.0.1"))
foreach ip in empty_list_of_ips
select {ip}
Finally, Thanks to