class itself let's say linker() returns refrence of 'Myclass' and another method tat just does print called output() and I have instance of Myclass created called 'link' so this is the code:
link.linker().output();
Does this have any practical use in real world applications?
It's called daisy chaining and yes it is used in applications.
Like what all could it be used with its fine if u give me abstarct examples
I can give you concrete example. Google for "builder pattern", "lombok builder example". Or you can also check out any rxjava or reactor tutorial, where call chaining is used as main paradigm. By the way, it's also called as "call chaining".
You're welcome. And also it's not necessarily must be "return reference to itself". It may be reference to any other object. Main idea is that the call chain should fluent and readable. Rxjava/reactor actually return you new instance of builder after each call. Also remembered great example: check out something like "spring security configuration", they also use it nicely
Обсуждают сегодня