OCLOperators Bag
(Created page with "You can use Set with { } to create a set that you may use to loop over. A Bag can contain '''duplicates''', so it's just a collection of something. With Integers Bag{14,22...")
 
(Automatically adding template at the end of the page.)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
You can use Set with { } to create a set that you may use to loop over.
You can use Bag with { } to create a set you may use to loop over.


A Bag can contain '''duplicates''', so it's just a collection of something.
A Bag can contain '''duplicates''', so it's just a collection of something.


With Integers
With Integers:
  Bag{14,22,12,53,2,11,66}->collect(i| DoSomthingWithAnInt(i))  
  Bag{14,22,12,53,2,11,66}->collect(i| DoSomthingWithAnInt(i))  
With Strings
With Strings:
  Bag{'String', 'EmailAddress'}->collect(s| DoSomthingWithAString(s))  
  Bag{'String', 'EmailAddress'}->collect(s| DoSomthingWithAString(s))  
If you want to create a sequence of numbers (in order) you can use the [[Sequence operator]].
If you want to create a sequence of numbers (in order), you can use the [[Sequence operator]].


Other names for set: collection of strings, array of numbers, static array, initialize array, list of numbers
Other names for set: collection of strings, array of numbers, static array, initialize array, list of numbers


See also: [[OCLOperators Set]]
See also: [[OCLOperators Set]]
[[Category:OCLOperators]]
{{Edited|July|12|2024}}

Latest revision as of 15:38, 10 February 2024

You can use Bag with { } to create a set you may use to loop over.

A Bag can contain duplicates, so it's just a collection of something.

With Integers:

Bag{14,22,12,53,2,11,66}->collect(i| DoSomthingWithAnInt(i)) 

With Strings:

Bag{'String', 'EmailAddress'}->collect(s| DoSomthingWithAString(s)) 

If you want to create a sequence of numbers (in order), you can use the Sequence operator.

Other names for set: collection of strings, array of numbers, static array, initialize array, list of numbers

See also: OCLOperators Set

This page was edited 92 days ago on 02/10/2024. What links here