KM8: Using Dictionaries

Continuing the discussion from Store Values in Dynamically Created Variables?:

@peternlewis, many thanks for adding this new variable/object type. It will be really useful.

For all, here’s the KM Wiki on this: Dictionaries

Can this be used with an array, like in JavaScript?

var peopleList = [
  {FName: "John", LName: "Smith"},
  {FName: "Mary", LName: "Jones"}
];

console.log(peopleList[1].LName);
//-->Jones

How would I create the above in KM8?

You can’t index the dictionary like an array, but you can iterate through the dictionaries and through a dictionaries keys.

So you can get them that way, or you could build a string array of the keys if you wanted.

As I mentioned in the other thread, we need a good, complete, example, please.

1 Like

For an example, see: