flash.utils.TypedDictionary usage?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

flash.utils.TypedDictionary usage?

Michel Oster
Michael Baczynski wrote :

 > I have problems with the TypedDictionary class.

Hallo,

I know nothing about 'TypedDictionary' class, but when I look your
'source' :

        var key:String = "key";
        var val:String = "val";
        d.set(key, val);

it looks like a haXe-Standard Lib named 'Hash<String>'

The advantage of using 'Hash<String>' in haXe
is that your code becomes 'multiplatform' ( flash, js, php ... ) :

        var d: Hash<String> = new Hash();
        var key:String = "key";
        var val:String = "val";
        d.set(key, val);

Hope it helps,

Michel


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: flash.utils.TypedDictionary usage?

Michael Baczynski-2
seems like it works fine using a custom class as a key, but not for
primitive types:

class Test {
    public function new() {}
}

var d:TypedDictionary<Test, String> = new TypedDictionary();
d.set(new Test(), "foo"); //ok

is this because primitives doesn't have a constructor, e.g. new Int(5)
doesn't work ?

michael



Michel Oster wrote:

> Michael Baczynski wrote :
>
> > I have problems with the TypedDictionary class.
>
> Hallo,
>
> I know nothing about 'TypedDictionary' class, but when I look your
> 'source' :
>
>     var key:String = "key";
>     var val:String = "val";
>     d.set(key, val);
>
> it looks like a haXe-Standard Lib named 'Hash<String>'
>
> The advantage of using 'Hash<String>' in haXe
> is that your code becomes 'multiplatform' ( flash, js, php ... ) :
>
>     var d: Hash<String> = new Hash();
>     var key:String = "key";
>     var val:String = "val";
>     d.set(key, val);
>
> Hope it helps,
>
> Michel
>
>


--
haXe - an open source web programming language
http://haxe.org