Hello Again This time is about the logic behind “For each” condition and dictionaries.
I replicated the solution to understand completely the exercise but I have some problems in these steps:
Variables:
Winners: New Dictionary(Of Int32,String) From {{2006,“Oscar Pereiro”},{2007,“Alberto Contador”}, {2008, “Carlos Sastre”}, {2009,“Alberto Contador”}, {2010, “Andy Schleck”}, {2011, “Cadel Evans”}, {2012,“Bradley Wiggins”}, {2013,“Chris Froome”}, {2014,“Vincenzo Nibali”},{2015,“Chris Froome”},{2016,“Chris Froome”},{2017,“Chris Froome”}, {2018,“Geraint Thomas”}}
In the first “For Each” where we use “.Values” Function, what is does is to create a new dictionary called “WinnerName” and has all the values from “Winners”, please, correct me if I’m wrong
In the next step, If condition:
WinnerCounts.ContainsKey(WinnerName)
WinnerCounts is the variable(dictionary string,Int32)
.ContainsKey function determines whether the dictionary(WinnerName?) contains tthe key (names) ?
This is the step I don’t understand, when is created this dictionary with all the names?