Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Operation of includes() operation
Operation of includes() operation [message #481862] Mon, 24 August 2009 15:19 Go to next message
Eclipse User
Originally posted by: c.k.holmes.lboro.ac.uk

Hi,
I have a class containing an attribute of type String, when instantiated
I expect the attribute to take any (one) of the values 'A', 'B', or
'C'. I wrote a simple helper operation to check the value against the
set of allowable values, however the include() operation doesn't appear
to return the expected result, see simple example below:

operation MyClass anOp() : Boolean {
var allowableItems : Set(String) := Set{'A', 'B', 'C'};
var item : String := 'B';
return allowableItems.includes(item);
}

It doesn't appear to be an address pointer issue as I can set item to
allowableItems.first() and still anOp() returns false. I think the
operation is running the following query:
Set{'A', 'B', 'C'}.includes('B')
Hence I expected the result 'true'. What am I doing incorrectly?

Best Wishes
Chris
Re: Operation of includes() operation [message #481902 is a reply to message #481862] Mon, 24 August 2009 16:53 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi Chris,

This is a known issue that I've fixed in my working copy - but is still
under testing for regressions - and it also affects the count()
operation. As a workaround you can use the select() method as follows:

return allowableItems.selectOne(i|i = item).isDefined();

Cheers,
Dimitris

Chris Holmes wrote:
> Hi,
> I have a class containing an attribute of type String, when instantiated
> I expect the attribute to take any (one) of the values 'A', 'B', or
> 'C'. I wrote a simple helper operation to check the value against the
> set of allowable values, however the include() operation doesn't appear
> to return the expected result, see simple example below:
>
> operation MyClass anOp() : Boolean {
> var allowableItems : Set(String) := Set{'A', 'B', 'C'};
> var item : String := 'B';
> return allowableItems.includes(item);
> }
>
> It doesn't appear to be an address pointer issue as I can set item to
> allowableItems.first() and still anOp() returns false. I think the
> operation is running the following query:
> Set{'A', 'B', 'C'}.includes('B')
> Hence I expected the result 'true'. What am I doing incorrectly?
>
> Best Wishes
> Chris
Re: Operation of includes() operation [message #574803 is a reply to message #481862] Mon, 24 August 2009 16:53 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi Chris,

This is a known issue that I've fixed in my working copy - but is still
under testing for regressions - and it also affects the count()
operation. As a workaround you can use the select() method as follows:

return allowableItems.selectOne(i|i = item).isDefined();

Cheers,
Dimitris

Chris Holmes wrote:
> Hi,
> I have a class containing an attribute of type String, when instantiated
> I expect the attribute to take any (one) of the values 'A', 'B', or
> 'C'. I wrote a simple helper operation to check the value against the
> set of allowable values, however the include() operation doesn't appear
> to return the expected result, see simple example below:
>
> operation MyClass anOp() : Boolean {
> var allowableItems : Set(String) := Set{'A', 'B', 'C'};
> var item : String := 'B';
> return allowableItems.includes(item);
> }
>
> It doesn't appear to be an address pointer issue as I can set item to
> allowableItems.first() and still anOp() returns false. I think the
> operation is running the following query:
> Set{'A', 'B', 'C'}.includes('B')
> Hence I expected the result 'true'. What am I doing incorrectly?
>
> Best Wishes
> Chris
Previous Topic:Operation of includes() operation
Next Topic:ANT Script for ETL
Goto Forum:
  


Current Time: Tue Sep 30 13:53:48 GMT 2014

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

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