0

In a component he uses something like:

Method (Obj: MyClass) { .... }

It's a shorthand for Obj = new MyClass ?

And if in the constructor of MyClass there is an argument needed, this should be Obj = new MyClass (argument) ? and the Obj: MyClass, still works?

1 Answer 1

1

It's a shorthand for Obj = new MyClass ?

No, it is not. It only specifies that Method receives an argument (Obj reference inside the method) of type MyClass. It means the argument passed to Method must be an instance of MyClass.

Example of correct usage of Method:

const ob = new MyClass(); // supose `MyClass` constructor does NOT requieres any argument
Method(ob);

Example of incorrect usage of Method:

Method();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.