head()
returns the first element in a list.
Syntax: head(list)
Returns: The type of the value returned will be that of the first element of list
.
Arguments
Name | Description |
list | An expression that returns a list. |
Example
RETURN head([4, 3, 7, null, 2])
The value returned will be the first element among all the expressions in the list passed to the function, which in this case will be 4.
Considerations
head(null)
returnsnull
.- If the first element in
list
isnull
,head(list)
will returnnull
. head([])
returnsnull
.
Example
RETURN head([2, null, "Hello, World!", true, -1, 2020])
Returns the following Result
head([2, null, "Hello, World!", true, -1, 2020]) |
2 |
Example
RETURN head(["Hello, World!", true, -1, 2020, 2])
Returns the following Result
head(["Hello, World!", true, -1, 2020, 2]) |
"Hello, World!" |
Example
RETURN head([true, -1, 2020, 2, "Hello, World!"])
Returns the following Result
head([true, -1, 2020, 2, "Hello, World!"]) |
true |
Example
RETURN head([null, true, -1, 2020, 2, "Hello, World!"])
Returns the following Result
head([null, true, -1, 2020, 2, "Hello, World!"]) |
null |
Example
RETURN head(["Hello, World!"])
Returns the following Result
head(["Hello, World!"]) |
"Hello, World!" |
Example
WITH [true, "Hi", null, 7, 17, false, 2020] as list
RETURN head(list)
Returns the following Result
head(list) |
true |
Example
WITH [false] as list
RETURN head(list)
Returns the following Result
head(list) |
false |
Example
RETURN head([])
Returns the following Result
head([]) |
null |
Example
WITH [] as list
RETURN head(list)
Returns the following Result
head(list) |
null |
Example
RETURN head(null)
Returns the following Result
head(null) |
null |