Your list newSetRatio
is emptied inside if
condition. If that condition returns false
, it will contain the values from previous iteration. Since it is populated in every iteration, outside of condition, whenever condition returns false
all items from assetSharingRatios
will be added without list being cleared previously. So in case assetSharingRatios
has not changed and your codnition returns false
, newSetRatio
will have all duplicates. And if condition keeps resulting in false
, items in newSetRatio
will triple and so on.
Another point is your last line of code contributePartnersData.assetSharingRatio = newSetRatio;
If you fix newSetRatio
behavior, then last item added into contributingPartnersData
will get new assetSharingRatio
values whenever if
condition is false
. Not sure if this is intended, looks a bit strange. Is this why those last three lines of code are outside of 'if`?