Is there any specific difference between collections and Int

Posted by Kanchana Gopalakrishnan on 07-Dec-2016 08:18

When we use a collection attribute for mathematical operations, I feel no difference between collection operators and integer operators.Is it so???

Can we replace the entire collection to an other collection?

Posted by mparish on 07-Dec-2016 10:26

Collection operators are very different from integer operators.
Collection operators work on set of objects, each of which may have many attributes.
Integer operators work on single attributes.
 
However there are some operators (such as +, +=, - and -=) that can be used with collections and with integers but their behavior is different.
For example
Assuming total and discount are integer attributes:
Customer.total-=Customer.discount subtracts the value of discount from the value of total
This is a shorter way of writing Customer.total=Customer.total-Customer.discount
 
In contrast, when you are working with collections, the same operators add or remove instances from customers.
customers+=Customer.new would create a new instance of Customer and add it to the collection alias named collections.
 
Take a look at this articles for a more complete example:
https://dmcommunity.files.wordpress.com/2015/09/collections-of-cars-corticon.pdf
https://dmcommunity.files.wordpress.com/2015/08/duplicates-corticon.pdf
https://dmcommunity.files.wordpress.com/2016/11/passenger-rebooking-decision-modeling-challenge-corticon.pdf
https://community.progress.com/community_groups/corticon/m/documents/1386
When you use collections there are some very powerful operators available to you:
Also take a look at the Corticon documentation which describes collections
 

All Replies

Posted by mparish on 07-Dec-2016 10:26

Collection operators are very different from integer operators.
Collection operators work on set of objects, each of which may have many attributes.
Integer operators work on single attributes.
 
However there are some operators (such as +, +=, - and -=) that can be used with collections and with integers but their behavior is different.
For example
Assuming total and discount are integer attributes:
Customer.total-=Customer.discount subtracts the value of discount from the value of total
This is a shorter way of writing Customer.total=Customer.total-Customer.discount
 
In contrast, when you are working with collections, the same operators add or remove instances from customers.
customers+=Customer.new would create a new instance of Customer and add it to the collection alias named collections.
 
Take a look at this articles for a more complete example:
When you use collections there are some very powerful operators available to you:
Also take a look at the Corticon documentation which describes collections
 

This thread is closed