A Dictionary allows mapping of String keys to arbitrary values. If the value of a key is given one type and then retrieved with a different type (for example, setInt ... getObject), the result is unspecified.

Static methods

staticfromObject(obj:Dynamic):Dictionary

Returns a Dictionary with the same contents as the given dynamic object. Dynamic object is a native Haxe feature, and can be hard to work with in the target languages, so this method exists so you can work with their data using the Dictionary methods.

All arrays within the object will be converted to collections.

Classes in the connect.api package work with dynamic objects.

Constructor

new()

Creates a new Dictionary.

Methods

clear():Void

Removes all keys from this Dictionary.

copy():Dictionary

Returns a shallow copy of this Dictionary. The order of values is undefined.

exists(key:String):Bool

Returns true if key has a mapping, false otherwise. If key is null, the result is unspecified.

get(key:String):Dynamic

Returns the current mapping of key as an Object.

If no such mapping exists, null is returned.

Note that a check like dict.get(key) == null can hold for two reasons:

  1. The dictionary has no mapping for key
  2. The dictionary has a mapping with a value of null

If it is important to distinguish these cases, exists() should be used.

If key is null, the result is unspecified.

getBool(key:String):Bool

Returns the current mapping of key as a Bool.

If no such mapping exists, false is returned.

Note that a check like dict.get(key) == false can hold for two reasons:

  1. The dictionary has no mapping for key
  2. The dictionary has a mapping with a value of false

If it is important to distinguish these cases, exists() should be used.

If key is null, the result is unspecified.

getFloat(key:String):Float

Returns the current mapping of key as a Float.

If no such mapping exists, 0.0 is returned.

Note that a check like dict.get(key) == 0.0 can hold for two reasons:

  1. The dictionary has no mapping for key
  2. The dictionary has a mapping with a value of 0.0

If it is important to distinguish these cases, exists() should be used.

If key is null, the result is unspecified.

getInt(key:String):Int

Returns the current mapping of key as an Int.

If no such mapping exists, 0 is returned.

Note that a check like dict.get(key) == 0 can hold for two reasons:

  1. The dictionary has no mapping for key
  2. The dictionary has a mapping with a value of 0

If it is important to distinguish these cases, exists() should be used.

If key is null, the result is unspecified.

getString(key:String):String

Returns the current mapping of key as a String.

If no such mapping exists, an empty string is returned.

Note that a check like dict.get(key) == "" can hold for two reasons:

  1. The dictionary has no mapping for key
  2. The dictionary has a mapping with a value of ""

If it is important to distinguish these cases, exists() should be used.

If key is null, the result is unspecified.

isEmpty():Bool

Returns true if this Dictionary has not keys

Returns:

Bool

iterator():Iterator<Dynamic>

Returns an Iterator over the values of this Dictionary. The order of values is undefined.

keys():Iterator<String>

Returns an Iterator over the keys of this Dictionary. The order of keys is undefined.

remove(key:String):Bool

Removes the mapping of key and returns true if such a mapping existed, false otherwise. If key is null, the result is unspecified.

set(key:String, value:Dynamic):Dictionary

Maps key to a value. If key already has a mapping, the previous value disappears. If key is null, the result is unspecified.

setBool(key:String, x:Bool):Dictionary

Maps key to a Bool value. If key already has a mapping, the previous value disappears. If key is null, the result is unspecified.

setFloat(key:String, x:Float):Dictionary

Maps key to a Float value. If key already has a mapping, the previous value disappears. If key is null, the result is unspecified.

setInt(key:String, x:Int):Dictionary

Maps key to an Int value. If key already has a mapping, the previous value disappears. If key is null, the result is unspecified.

setString(key:String, x:String):Dictionary

Maps key to a String value. If key already has a mapping, the previous value disappears. If key is null, the result is unspecified.

toObject():Dynamic

Returns a dynamic object with the same contents as the this Dictionary. Dynamic object is a native Haxe feature, and can be hard to work with in the target languages, so this method exists so you can work with their data using the Dictionary methods and then convert them back to dynamic objects.

All collections within the object will be converted to arrays.

Classes in the connect.api package work with dynamic objects

toString():String

Returns a JSON string representation of this Dictionary.