First
Returns a sequence containing the first value in the given sequence, or empty if the given sequence contains no values.
Syntax
Sequence.First
· [sequence]
Parameters
- sequence
- The sequence.
Return Value
A sequence with either zero or one value.
Remarks
This can be used in conjunction with Sequence.Skip to get a specific item in a sequence.
As an example, the following would get the fourth element selected by the MySelector
selector:
Sequence.First
· Sequence.Skip
· 3
· Select.MySelector
Note that skipping 3 elements gives the fourth element because skipping 0 elements would give the first one. If MySelector
selects less than 4 elements, an empty sequence will be produced. If this functionality is needed more than once in a project, it can also be generalized into a function that takes a zero based index and a sequence:
function (index selector)
Sequence.First
· Sequence.Skip
· index
· selector
Supposing the function was pasted into a global called GetElement
, it could be used anywhere within the project like this:
GetElement
· 3
· Select.MySelector