0

Lets suppose i have a class A which implements this function:

function do_Some_Thing_With_Points(obj, P)
obj.other_function();

I would like to understand the following use of this function:

Let a be an instance of A and:

a.do_Some_Thing_With_Points(P);

Is it ok to not pass the parameter obj, and what does it mean? Thanks!

1 Answer 1

2

You are actually passing obj, which is in your case a. This is because this

a.do_Some_Thing_With_Points(b);

is equivalent to

do_Some_Thing_With_Points(a, b);

at least if only one instance of the class is provided to the function.

The syntax of the second case is not recommended, since the 'owner' of the method is not provided explicitly (if b would be an instance of class A as well, this method owner is not obvious). I just included it to help you understand where the obj comes from.

Sign up to request clarification or add additional context in comments.

5 Comments

thank you. I have 1 more question: What does it mean to do a.merge(b) where b is also an instance of A?
I dont know. That completely depends on the class and how the function merge is implemented.
isnt there a matlab standard for it?
Maybe there is an abstract class with a merge function. But I really cant answer your question if I dont know your class definition.
Im learning a code that i have got. There is a a class that inherits from handle and this class is using obj.merge(other obj from same type).

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.