Libraries: JSON - page 2

 
Sergey Gridnev #:
I haven't looked at the library code, but judging by the fragment you presented, the setProperty and Add methods return a reference to the object (this), so you can refer to the class method again via a dot. This allows you to collect such chains of calls.

I understand that:

....add().add()

But I haven't seen how a method call is attached to a constructor. And how it corresponds with new.

 
Edgar Akhmadeev #:

I understand that:

but I haven't seen how a method call is attached to a constructor. And how that fits with new.

new returns a reference.
The constructor has nothing to do with it.
 
Sergey Gridnev #:
The designer had nothing to do with it
I see it this way
= new JSON::Object().setProperty()

Okay, it seems like it can't be explained in a nutshell, and no one wants to be more thorough.

 
Edgar Akhmadeev #:
I see it like this

Okay, it seems like it can't be explained in a nutshell, and no one wants to be more thorough.

Look at it this way:
= (new JSON::Object()).setProperty())
 
Sergey Gridnev #:
Look at it this way:
= (new JSON::Object()).setProperty()
Well, yes, by the result it is, there are no options. But I don't break this particular syntax rule. Although I know the basics of OOP. I apply it, except for the most sophisticated ones. I remember C++ (40 years ago). Actually, my first language was assembler.