Tech Tip: New .first() function in the Collection Class
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: July 20, 2023
As of 4D V20, the .first() function can be called on a Collection. The .first() function returns the first element of the collection.
Note:
This function does not modify the original collection.
Returns Undefined if the collection is empty
Collection Example:
var $col; $emptyCol : Collection var $first : Variant $col:=New collection("hello"; 10; 20; 30; "world") $first:=$col.first() // "hello" $emptyCol:=New collection() // $first:=$emptyCol[0] //would return error $first:=$emptyCol.first() // returns Undefined |