I see some codes which go like this: abc.(xyz).(efg).(klm). I understand that in b4x, object oriented, in particular, inheritance is done thru encapsulation, but how can I make an object capable of doing like that?
1.There is no inheritance in B4X.
2. The syntax of the code you posted is wrong.
You can do:
B4X:
abc.DoSomething(xyz).AndAnotherThing(efg).
Any sub that returns a specific type of object will behave like this:
B4X:
Public Sub DoSomething(x As Int) As SomeObject
If you are trying to implement the "builder" pattern where you can chain methods that all act on the same instance, as happens with StringBuilder, CSBuilder and others:
B4X:
Public Sub Append(S As String) As StringBuilder
...
Return Me
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.