I have a method as so: Now if I do this: It’ll work perfectly fine. However, if I try to do this : It doesn’t seem to work at all. It says “variable expected”. I understand that new Foo() in itself, creates a new Foo object, but even if I use the factory, it should just override the anonymous object