I have a map object that is stored <Id, String>where Id is the contact identifier, and the line is the generated email.
I successfully walked through the map and was able to pull out the values (part of String) when I iterate over the map.
What I would like to have is also to capture the key when I capture the value. This is very easy to do in most languages, but I can’t figure out how to do this on top.
This is what I have right now:
Map<Id,String> mailContainer = new Map<Id,String>{};
for(String message : mailContainer.values())
{
System.debug(message);
}
What I would like is something like this:
for(String key=>message : mailContainer.values())
{
System.debug(key);
System.debug(message);
}
Thanks in advance!
source
share