Skip to content

Instantly share code, notes, and snippets.

@superfell
Created April 23, 2014 20:51
Show Gist options
  • Save superfell/11231957 to your computer and use it in GitHub Desktop.
Save superfell/11231957 to your computer and use it in GitHub Desktop.
SObject == issue in apex
Account a1 = new Account(name = 'woop');
Account a2 = new Account(name = 'woop');
Account a3 = (Account)JSON.deserialize('{"name" : "woop"}', Account.class);
Account a4 = (Account)JSON.deserialize(JSON.serialize(a1), Account.class);
System.debug( a1 == a2 ); // true
System.debug( a1 === a2); // false
System.debug( a3 == a1 ); // true
System.debug( a4 == a1 ); // false but should be true
System.debug( a3 == a4 ); // false but should be true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment