[Type] Map

Part of: mobl
Inherits from: mobl::Object

Represents a map, also known as hash map or dictionary. It maintains a key-value store.

Instantiation

A new Map can be created using the Map<K,V>() constructor, where K is the type of the keys and V the type of values.

Example:

var m = Map<String, Object>();
m.set("name", "Zef");
m.set("age", 27);

Instance methods

get(key : K) : V

Returns the value associated with key, returns null when no such key has been defined.

Example:

var m = Map<String, Object>();
m.set("name", "Zef");
m.set("age", 27);
m.get("name") // -> "Zef"

set(key : K, value : V) : void

Sets the value associated with key to value.

Example:

var m = Map<String, Object>();
m.set("name", "Zef");

keys() : [K]

Returns a list of defines keys.

Example:

var m = Map<String, Object>();
m.set("name", "Zef");
m.set("age", "Zef");
m.keys() // -> ["name", "age"]
mobl/map.txt · Last modified: 2013/10/01 02:28 (external edit)