Just starting out.
Under “RPA Developer - Production Ready Essentials”, part 3 - Data Manipulation, lesson 8 - Practice 3 - Dictionaries & Integers, this is the solution given.
Start the project as a sequence and create a new Dictionary with types (String, Int32)
Loop through the values in the first Dictionary with a ’ For Each ’ (“ForEach WinnerNames in FirstDictionaryName.Values”) and check if the value is already present as key in the new Dictionary using the ‘.ContainsKey’ method inside an ’ If ’ activity (“SecondDictionaryName.ContainsKey(WinnerName)”):
A. if the condition is met, use an ’ Assign ’ activity to increase the value of the corresponding key: WinnerCounts(WinnerName) = WinnerCounts(WinnerName) + 1
B . if the condition is not met, add the key to the second Dictionary with value “1” using an ’Invoke Method’ activity with the TargetObject the second Dictionary name and ’ Add ’ as MethodName
- Loop through the second Dictionary using ’ For Each ’ (“ForEach winner in SecondDictionaryName”) and use an ’ If ’ to write a differentiated text for those with 1 win vs. those with more wins using ‘Write Line’.
As seen in the bold words, I am wondering if I can use ‘Add to Collection’ Activity instead? What is the difference between Invoke Method (Add) and ‘Add to Collection’ Activity? Thankyou