JS.Class & Uniquity

11 views
Skip to first unread message

Maël Nison

unread,
Feb 10, 2012, 11:16:25 AM2/10/12
to jsclass-users
Hi,

Assuming this :

var C = new JS.Class( 'Foobar', {} );

var a = new C( );
var b = new C( );

Will this statement always be true ?

a.toString( ) != b.toString( )

Thanks,

--
Maël Nison
Epitech 2014, Paris - Astek

James Coglan

unread,
Feb 10, 2012, 11:21:20 AM2/10/12
to jsclas...@googlegroups.com
On 10 February 2012 16:16, Maël Nison <nison...@gmail.com> wrote:
Assuming this :

var C = new JS.Class( 'Foobar', {} );

var a = new C( );
var b = new C( );

Will this statement always be true ?

a.toString( ) != b.toString( )

Yes, if you don't override toString() or hash() -- the default toString() given by JS.Class includes the object's hash, which the default hash() implementation gives a different value for every object. However certain data structures override hash() to match up with the equals() contract -- see http://jsclass.jcoglan.com/equality.html
Reply all
Reply to author
Forward
0 new messages