Run this in Execute Anonymous
system.debug( new SObject[]{} instanceof SObject );
"compileProblem": "Operation instanceof is always false since an instance of List is never an instance of SObject"
Good to know this. But now try that:
Object o1 = new Integer[]{};
Object o2 = new SObject[]{};
system.debug( o1 instanceof Integer ); // ==> false, as expected
system.debug( o2 instanceof SObject ); // ==> true !!!
That Integer[]
is not an instance of Integer
sounds reasonable. But why the heck SObject[]
is an instance of SObject
??
Any ideas what is going on here?