Collection Initializers
A collection initializer uses a shorter syntax to let you make a collection and fill it with an initial set of values. Collection initializers are typically used to make a collection from a set of known values. Examples include the names of months and a list of locations that you can use to validate user input.
The statement New
becomes a collection initializer when you start the second line with Begin Call
.
Then you can supply an optional method name that each initializer calls.
The default method is Add
.
Then you can supply the data.
New SiteList sites
Begin Call
"Google Search", "https://google.com/"
"YouTube", "https://youtube.com/"
"Facebook", "https://facebook.com/"
"Wikipedia", "https://www.wikipedia.org/"
End
New Array[String] months
Begin Call
"Jan"; "Feb"; "Mar"; "Apr";
"May"; "Jun"; "Jul"; "Aug";
"Sep"; "Oct"; "Nov"; "Dec"
End
New Map[String, String] states
Begin Call
"AK", "Alaska"; "AL", "Alabama";
"AR", "Arkansas"; "AZ", "Arizona";
"CA", "California"; // ...
End