OCLOperators collectNested
No edit summary
(Automatically adding template at the end of the page.)
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=== collectNested ( expr : OclExpression ) : Collection(T2) ===
Returns a collection containing all the elements contained in self on which we applied the OclExpression expr. The results won't be flattened. The type of the resulting collection depends on the type of self.
Returns a collection containing all the elements contained in self on which we applied the OclExpression expr. The results won't be flattened. The type of the resulting collection depends on the type of self.


For the purpose of this example, we'll assume here that we have a Class *Person* with a reference *children*. Our model contains two persons such as *person1.children = {James, Jane}* and *person2.children = {John}*.
For the purpose of this example, we'll assume here that we have a Class <code>Person</code> with a reference <code>children</code>. Our model contains two persons such as <code>person1.children = {James, Jane}</code> and <code>person2.children = {John}</code>.
{| class="wikitable"
{| class="wikitable"
!Expression
!Expression
Line 9: Line 10:
|<nowiki>Sequence{Sequence{James, Jane}, Sequence{John}}</nowiki>
|<nowiki>Sequence{Sequence{James, Jane}, Sequence{John}}</nowiki>
|}
|}
[[Category:OCL Collection Operators]]
{{Edited|July|12|2024}}

Revision as of 15:41, 10 February 2024

This page was created by Stephanie@mdriven.net on 2023-03-27. Last edited by Edgar on 2025-01-20.

collectNested ( expr : OclExpression ) : Collection(T2)

Returns a collection containing all the elements contained in self on which we applied the OclExpression expr. The results won't be flattened. The type of the resulting collection depends on the type of self.

For the purpose of this example, we'll assume here that we have a Class Person with a reference children. Our model contains two persons such as person1.children = {James, Jane} and person2.children = {John}.

Expression Result
self.persons->collectNested(children.firstname) Sequence{Sequence{James, Jane}, Sequence{John}}
MDriven Chat

How would you like to chat today?

Setting up your conversation…

This may take a few moments