View on GitHub

NullCoaliescing

Null Coaliescing method using 4D

NVF

Allow to return the result of the passed formula($2) applyed to first element($1) if this element is non NULL otherwise return Undefined or optionnal third element ($3).

Why?

Apply one line Formula without checking if element is Null

Usage

Checking if could loop on collection (one line)

If (NVF ($collection;Formula($1.length>5)))
	For each ($element;$collection)

	End for each
End if

Explanation

You cannot check a collection size if this collection is NULL .

If ($collection.lenght>0)

Because the second condition will be evaluated using 4d you cannot do that either

If (($collection#Null) & ($collection.lenght>5))
...

The only solution is two lines of code

If ($collection#Null)
  If($collection.lenght>0)
...

Test

see test_NVF


Elvis