It is not a real bug, but it is a ... uhm... "an incorrect behaviour".
In a Class I have a property, setSomething(what as int).
The editor, rightly, does not list setSomething as available method ("intellisense") although it is also a public routine but if you use it like a method (objMyClass.setSomething(12)) it works; instead, this should be an error reported by the compiler, I think.
Sub Class_Globals
Private mName As String
End Sub
Public Sub setName(Name As String)
mName = Name
End Sub
Public Sub getName As String
Return mName
End Sub
Name would be a Property, then you should set its value using:
B4X:
Dim Person As clsPerson
Person.Initialize
Person.Name = "Klaus"
Person.setName("Erel") ' this should not work, and it should show an error.
For me both are correct.
Just two different ways of writing.
I think that Person.setName("Erel") is also useful for compatibility with 'old' code written before the introduction of the propety routines.
I agree with Klaus. This is good for compatibility with old code.
There is another delicate point here. You must use setName inside the class to call the method (and it will show in the autocomplete list). So I don't see any harm if someone also uses this syntax from a different module.
I agree with Klaus. This is good for compatibility with old code.
There is another delicate point here. You must use setName inside the class to call the method (and it will show in the autocomplete list). So I don't see any harm if someone also uses this syntax from a different module.
I happened to talk to a person about a method that from my point of view does not exist.
However, inside the class you should not call the property but set the member variable associated with it.
As for compatibility (somewhat dated) any methods whose name begins with "set" should simply become "Set ..." in the old projects (a replace would be enough).