Bug? Property: combination of public getter, private setter

wl

Well-Known Member
Licensed User
Longtime User
Hi,

Not sure this a bug, or works by design...

When you combine a public getter of a property with a private setter, it seems this is not recognized as a property:

B4X:
Private pDemo as String
...

private sub setDemo (demo as String)
  pDemo = demo
end sub

public sub getDemo as string
  return pDemo
end sub

It could be useful to be able to do so, for example
- you create a helper class in a library and want to be able to set the property to a value. Since the setter is private, you can do so with CallSub
- the library consumer code should only be able to get the property value. This can be done by reading the property [readOnly].

A workaround of course would be to rename the private setter to another name.

Thanks
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…