Basic4android v2.20 will include two new language features that will help with writing "cleaner" code:
- Declaration and assignment in the same line:
- For Each block. A simpler way to iterate over all values in a collection or array:
- Declaration and assignment in the same line:
B4X:
Dim h As String = "Hello"
'The value expression can be located before or after the type.
'This code is also valid:
Dim i1 = 1, i2 = 2, i3 = 3 As Int
- For Each block. A simpler way to iterate over all values in a collection or array:
B4X:
'Numbers is a List or array.
For Each n As Int In Numbers
Sum = Sum + n
Next
For Each v As View In Activity
If v Is Label Then
Dim lbl As Label = v
lbl.TextSize = 20
End If
Next
'Disable several buttons:
For Each b As Button In Array As Button(btn1, btn2, btn3, btn4, btn5)
b.Enabled = False
Next