list
list
keyword can be used to create an array or list of values. The list
keyword is followed by the data type of the values that the list will contain.list
list
-- <data-type> list <list-name>: -- <value> -- <value> -- <value> -- ... -- end: <list-name>
Also make sure to use the end syntax -- end: <list-name>
to mark the end of the list during initialization.
weekdays
, you would use the following syntax:-- string list weekdays: -- string: Sunday -- string: Monday -- string: Tuesday -- string: Wednesday -- string: Thursday -- string: Friday -- string: Saturday -- end: weekdays
This creates a new variable called weekdays
, which is a list of string
s. The list is initialized with seven strings representing the days of the week.
ftd
are immutable, which means that their contents cannot be changed after they are initialized. However, you can make a list mutable by prefixing it with a $
symbol, like this:-- string list $weekdays: -- end: $weekdays
-- record person: caption name: body bio: -- person list people: -- person: Amit Upadhyay Amit is CEO of FifthTry. -- person: Shobhit Sharma Shobhit is a developer at FifthTry. -- end: people
list
of person
objects, called it people
, and created two person
objects and inserted them the people
list.ftd.ui
type as a listftd.ui list
type or children
type to pass a UI component in a list.ftd.ui list
type-- ftd.ui list uis: -- ftd.text: Hello World! -- ftd.text: I love `ftd`. -- end: uis
children
type-- foo: -- ftd.text: Hello World! -- ftd.text: I love `ftd`. -- end: foo -- component foo: children uis: ... some code here -- end: foo
Once you have created a list, you can access its elements using indexing or looping.
Once you have created a list, you can access its items using their index. Inftd
, indexing starts at 0. Or you can useloop
ftd
, you can use the $loop$
keyword to iterate over a list. Here’s an example:-- ftd.text: $obj $loop$: $weekdays as $obj
weekdays
list on a separate line. Similarly, To iterate over a uis
list, you would use the following syntax:-- obj: $loop$: $uis as $obj
ftd
.You can access an element of a list by its index. In ftd
, list indexing is zero-based, which means the first element of a list has an index of 0, the second element has an index of 1, and so on. You can use the .
operator to access an element of a list by its index.
weekdays
list, you would use the following syntax:-- ftd.text: $weekdays.0
uis
list, you would use the following syntax:-- uis.0:
$processor$
$processor$
-- string list foo: $processor$: some-list
Here the value of the list will be provided by the some-list
processor.
$processor$
as well:-- string list $foo: -- end: $foo -- $foo: $processor$: some-list
Have a question or need help?
Visit our GitHub Q&A discussion to get answers and subscribe to it to stay tuned.
Join our Discord channel and share your thoughts, suggestion, question etc.
Connect with our community!We welcome you to join our Discord community today.
We are trying to create the language for human beings and we do not believe it would be possible without your support. We would love to hear from you.