Skip to main content



      Home
Home » Modeling » OCL » collect equivalent for one element
collect equivalent for one element [message #1752332] Sat, 21 January 2017 13:05 Go to next message
Eclipse UserFriend
I am new in OCL. How can I write OCL expression below for one element?

s.source.elements -> collect (s|thisModule.CreateMatchClass(s))

[Updated on: Sat, 21 January 2017 13:06] by Moderator

Re: collect equivalent for one element [message #1752333 is a reply to message #1752332] Sat, 21 January 2017 14:01 Go to previous messageGo to next message
Eclipse UserFriend
Hi

I have no idea, since I cannot understand your question.

Once you learn to express your intended computation in a clear (declarative) way you will find that transliteration into OCL is quite straightforward. Practice your exposition.

Regards

Ed Willink
Re: collect equivalent for one element [message #1752346 is a reply to message #1752333] Sun, 22 January 2017 13:45 Go to previous messageGo to next message
Eclipse UserFriend
In other words, I don't understand which elements does the above code collect?
Since "collect" is used when we have more than one element, if I have one element (instead of elements), what changes occure to "-> collect (s|thisModule.CreateMatchClass(s))" part of that expression?
Re: collect equivalent for one element [message #1752348 is a reply to message #1752346] Sun, 22 January 2017 14:12 Go to previous messageGo to next message
Eclipse UserFriend
Hi

collect is for multiple elements.

If you only have one element why would you want to collect all one of it? For comparison, if you have a Java loop counter, why would you declare it as "int[] i" rather than "int i", or why would you want to wrap a single calculation in a loop?

You need to express your intent clearly.

Regards

Ed Willink
Re: collect equivalent for one element [message #1752371 is a reply to message #1752348] Mon, 23 January 2017 01:36 Go to previous messageGo to next message
Eclipse UserFriend
For one element is below code true?
s.source.thisModule.CreateMatchClass(s)
Re: collect equivalent for one element [message #1752384 is a reply to message #1752371] Mon, 23 January 2017 04:24 Go to previous messageGo to next message
Eclipse UserFriend
Hi

No idea.

What is "s"?
What is "source"?
What is "thisModule"?
What is "CreateMatchClass"?

See https://wiki.eclipse.org/OCL/ForumNetiquette

Regards

Ed Willink

Re: collect equivalent for one element [message #1752440 is a reply to message #1752384] Mon, 23 January 2017 13:51 Go to previous message
Eclipse UserFriend
I get my answer in another site. thanks for your time.
Previous Topic:Of surname propagation, another nest.
Next Topic:Problem in navigating references
Goto Forum:
  


Current Time: Tue Apr 29 12:20:53 EDT 2025

Powered by FUDForum. Page generated in 0.07514 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top