Is there any specific difference between collections and Integer(specifically for the equating and adding operations)? - Forum - Corticon - Progress Community

Is there any specific difference between collections and Integer(specifically for the equating and adding operations)?

Forum

Is there any specific difference between collections and Integer(specifically for the equating and adding operations)?

This question is answered

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?

• 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

All Replies
• 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