Skip to content

Dictionary variables in jask

Julius Paffrath edited this page Sep 11, 2018 · 3 revisions

A dictionary in jask is an unsorted collection of key-value pairs. Dictionary variables in jask can store any type of data, even lists and other dictionaries. Creating a new dictionary is straight forward:

store dictionary() in myDictionary

By creating a new dictionary, you can provide keys and values:

store dictionary("First Key":"First value":"Second Key":"Second value") in myDictionary

If you want to access the stored values, use the get functionality:

; this will print "First value"
printLine(dictionaryGet(myDictionary:"First Key"))

If you want to put new values in the dictionary, use the put functionality:

assign dictionaryPut(myDictionary:"New key":"New value") to myDictionary

You can easily iterate all mapped key-value pairs:

for key in dictionaryGetKeys(myDictionary)
  printLine("Key ":key:" is mapped to value ":dictionaryGet(myDictionary:key))
endrun

Visit Internal Functions Wiki to see all implemented dictionary functions.