You need to sign in to do that
Don't have an account?
navaneetha.cm1.3887470963815178E12
How the list gets updated with additional values while returning back to a main method from a submethod
I have 2 methods, main and a submethod. In main method I will have a list having repeated items. In the submethod I have written a logic to remove duplicate. But when the list is returned back it will have extra values.
For example:
Main method() {
list<object> sampleList = {{color: red, qty:1}, {color : blue, qty: 1},{color: red, qty:1}, {color : blue, qty: 1}};
submethod(sampleList);
Here the List will have {{color: red, qty:2}, {color : blue, qty: 2},{color: red, qty:1}}; extra value added
Instead of {{color: red, qty:2}, {color : blue, qty: 2}};
}
submethod (list<object> sampleList) {
logic to remove duplicate;
updated list will now have {{color: red, qty:2}, {color : blue, qty: 2}}; Only 2 values
return;
}
Can anyone suggest how that additional value gets added and solution to avoid it?
For example:
Main method() {
list<object> sampleList = {{color: red, qty:1}, {color : blue, qty: 1},{color: red, qty:1}, {color : blue, qty: 1}};
submethod(sampleList);
Here the List will have {{color: red, qty:2}, {color : blue, qty: 2},{color: red, qty:1}}; extra value added
Instead of {{color: red, qty:2}, {color : blue, qty: 2}};
}
submethod (list<object> sampleList) {
logic to remove duplicate;
updated list will now have {{color: red, qty:2}, {color : blue, qty: 2}}; Only 2 values
return;
}
Can anyone suggest how that additional value gets added and solution to avoid it?
Did you try something like this :
Hope this helps
Gil
Question Solved ? Please mark as the best answer to help other users !
- the variable assignment from the submethod :
- the return statement in the submethod
Hope this helps
Gil
Question Solved ? Please mark as the best answer to help other users !