You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 13, 2018. It is now read-only.
Jordan Kniest edited this page May 28, 2017
·
13 revisions
Here you can find explanations and examples for all collection methods.
Reduce
The reduce method converts a collection into some other type. For example it could be used to sum the items (converting the collection to a single integer)
// Create a new collection with three integer values (10, 20, 30)varcollection=newCollection<int>(10,20,30);// Reduce this collection to a single integer valuevarresult=collection.Reduce((value,item)=>{returnvalue+item;},0);// Print the result to the consoleConsole.Write(result);// The result is: 60
All
Return all items as an array. It is in fact an alias for the 'ToArray' method.
Structure:
publicTList[]All();
Example:
// Create a new collection with three integer values (10, 20, 30)varcollection=newCollection<int>(10,20,30);// Request all itemsvarresult=collection.All();// Print the first item to the consoleConsole.Write(result[0]);// The result is: 10