Is there a better [let] construct for multiple variable context [message #1733446] |
Fri, 27 May 2016 14:46 |
Shimon Zadok Messages: 24 Registered: May 2016 |
Junior Member |
|
|
I would like to store the result in a variable after a log sequence.
The let construct make is easier.
Though using it multiple times is not that pretty as it looks like nesting (while it is for the sake of scoping).
[let aPrimitiveType : PrimitiveType = aClass.clientDependency->asSequence()->first().supplier->filter(PrimitiveType)->asSequence()->first() ]
[let aStereoType : Stereotype = aPrimitiveType.getAppliedStereotypes()->asSequence()->first() ]
PrimitiveType: [aPrimitiveType.name /] StereoType: [aStereoType.name /]
[/let][/let]
Am I missing a better way? even for the retrieval of the first element?
[Updated on: Sat, 28 May 2016 08:37] Report message to a moderator
|
|
|
Re: Is there a better [let] construct for multiple variable context [message #1733764 is a reply to message #1733446] |
Tue, 31 May 2016 13:58 |
|
hi,
Pay attention that the "let" of Acceleo, as specified by the MOF Model-to-text Transformation Language, is the same as an "if <something>.oclIsKindOf" :
[let aPrimitiveType : PrimitiveType = xxx]
This will only enter the "let" body if "xxx" is of kind "PrimitiveType". Otherwise it'll just ignore the let.
That being said, there is no other way to keep variables around than the let except for the initialization of a block, but you wouldn't have access to every variable there, so that is your go-to method in such cases.
Laurent Goubet
Obeo
|
|
|
Powered by
FUDForum. Page generated in 0.05019 seconds