Setting Dictionary Key with Variable in APEX Script

   328   2   1
User Avatar
Member
9 posts
Joined: May 2018
Offline
Hello,

i am trying to set a dictionary Key with a Variable i defined and it yields me an error as you can see in the following screenshot:



Any ideas what is happening and how i could work around that issue?

Thanks,
Dani

Attachments:
dictVariables.png (68.6 KB)

User Avatar
Member
9 posts
Joined: May 2018
Offline
Okay got it, in case someone else also stumbles on this, here is the syntax that works:

Attachments:
dictSolution.png (6.8 KB)

User Avatar
Staff
195 posts
Joined: Jan. 2024
Offline
you can use set as well
test1: String = "aaa"
test2: String = "bbb"
d: Dict = {}
d.set(test1, test2)
  • Quick Links