Method calling method

Asked

Viewed 84 times

2

By my knowledge I can only call the method of a class only if I instantiate or if the method is static!

I can just do something myself class->metodo('var') or class::metodo('var').

But I’ve seen in some codes something like class->metodo('var')->outrometodo('').

Drupal himself uses something similar. Ex:

db_select('node', 'n')->execute()->fetchCol();

How do you make that kind of call, and what would be the advantages?

  • 1

    @Virgilionovic even being in java the idea is the same?

  • Yes. It’s the same logic.

  • Yes, see working repl it.

  • Really! I read the question and the answer here, and it worked! Recommends that I delete the question?

  • 1

    You can’t leave... you’re like a duplicate.

  • But a question has not been answered! How is the question! What would be the advantages? Does it represent any significant gain? Is there any recommendation for when to use or not?

  • 1

    https://answall.com/questions/105259/o-que%C3%A9-chaining-de-m%C3%a9todos/105433#105433 read

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.