Wish "Automatic" property creation

LucaMs

Expert
Licensed User
Longtime User
But since every "Sub" in B4x can be a procedure, a function or a property, it is not absolutely necessary.
You can use any routine almost as if it were a property. It is not a particularity of B4X, with VB Net and I think all other languages you can do this, but methods and properties are not exactly the same (otherwise properties would never have existed, in any programming language).
 

LucaMs

Expert
Licensed User
Longtime User
But since every "Sub" in B4x can be a procedure, a function or a property, it is not absolutely necessary.

Erel's code - B4XPlusMinus:
B4X:
Public Sub getSelectedValue As Object
    Return GetValueImpl (mSelectedIndex)
End Sub

Public Sub setSelectedValue (v As Object)
    If StringMode Then
        SetIndex(mStringItems.IndexOf(v), False)
    Else
        Dim n As Double = v
        SetIndex(Min(Size - 1, Max(0, Round((n - mStartRange) / mInterval))), False)
    End If
End Sub

I hope that since "even" Erel creates properties (and not just the stupid who is writing) will convince you that they are useful :)

Ok, he doesn't just use a variable in this property. However, what was written in the previous post is valid.
 
Top