(Automatically adding template at the end of the page.) |
(Adding message template to the top of the page) |
||
Line 1: | Line 1: | ||
{{message|Write the content here to display this box}} | |||
One important aspect of OCL worth noting is that it expands lists of lists to just a list. An example in plain English: <code>Thing.allinstances.Details</code> – this will come back as a set of details that are all the details from all the Things. If OCL had not expanded lists automatically, one could have expected a set of sets containing the details per thing. But this is not the case. The automatic expansion of lists of lists is sometimes referred to as the flattening of a collection – referring to the reduction of topology in the result. | One important aspect of OCL worth noting is that it expands lists of lists to just a list. An example in plain English: <code>Thing.allinstances.Details</code> – this will come back as a set of details that are all the details from all the Things. If OCL had not expanded lists automatically, one could have expected a set of sets containing the details per thing. But this is not the case. The automatic expansion of lists of lists is sometimes referred to as the flattening of a collection – referring to the reduction of topology in the result. | ||
Revision as of 22:16, 16 June 2024
Write the content here to display this box
One important aspect of OCL worth noting is that it expands lists of lists to just a list. An example in plain English: Thing.allinstances.Details
– this will come back as a set of details that are all the details from all the Things. If OCL had not expanded lists automatically, one could have expected a set of sets containing the details per thing. But this is not the case. The automatic expansion of lists of lists is sometimes referred to as the flattening of a collection – referring to the reduction of topology in the result.
Some OCL examples:
Examples | Results |
---|---|
Bag{'5','1','2','2','3','4'}->ascommalist | 5, 1, 2, 2, 3, 4 |
Bag{'5','1','2','2','3','4'}- >union(Bag{'1','2','2','3','6'})->ascommalist | 5, 1, 2, 2, 3, 4, 6 |
Bag{'5','1','2','2','3','4'}- >union(Bag{'1','2','2','3','6'})->asset- >ascommalist | 5, 1, 2, 3, 4, 6 |
Bag{'5','1','2','2','3','4'}- >union(Bag{'1','2','2','3','6'})->asset- >orderby(a|a)->ascommalist | 1, 2, 3, 4, 5, 6 |
Bag{'5','1','2','2','3','4'}- >intersection(Bag{'1','2','2','3','6'})- >orderby(a|a)->ascommalist | 1, 2, 2, 3 |
Bag{'5','1','2','2','3','4'}- >Difference(Bag{'1','2','2','3','6'})->orderby(a|a)- >ascommalist | 4, 5 |
Bag{'5','1','2','2','3','4'}- >SymmetricDifference(Bag{'1','2','2','3','6'})- >orderby(a|a)->ascommalist | 4, 5, 6 |
If you are in the context of a simple type like string, double, int, Datetime, or Boolean, MDriven will expose the simple operations that are available in the .net Framework. Test this in the OCL-Editor:
In this case, it is a string that is the result – and we can do string operations like compare, indexof, split, etc.
The numeric types float, double, decimal, and int are sort of apples of the same tree and MDriven exposes ways to go from all numeric types to decimal. The operator is called toDecimal.