I preferIt is such a special thing that it would be even better to use square brackets (although typing these is more cumbersome).
B4X:[Buttons.Get(2) As B4XView].Text = "less boring"
Buttons.Get(2).AsB4XView.Text = "More B4Xic"
That way you can't do it, mostly (but not only) because it wouldn't work with custom classes.I prefer
B4X:Buttons.Get(2).AsB4XView.Text = "More B4Xic"
<pedant>it would be(MyClass)lst.Get(i)
You are correct! My example was wrong as I did indeed wanted to mimic the Java syntaxcast the result of the Get
Very far from illogical. Language parsing is, by necessity extremely, nay ultimately, logical. Grouping is an often required order of execution indicator to the compiler.and illogical
Dim j As String = $"{
data: {
key1: value1,
complex_key2: {key: value2}
},
items: [0, 1, 2]
}"$
Dim parser As JSONParser
parser.Initialize(j)
Dim m As Map = parser.NextObject
Dim value1 As String = m.Get As Map("data").Get("key1")
Dim value2 As String = m.Get As Map("data").Get As Map("complex_key2").Get("key")
Dim FirstItemInList As String = m.Get As List("items").Get(0)
For Each item As Int In m.Get As List("items")
Log(item)
Next
Dim value2 As String = m.Get As Map("data").Get As Map("complex_key2").Get("key") As String
Right! One is going to get used to it, but I can see the power in it.Almost. It should be:
I 've stared at the code for ten minutes and I just can't parse it.Another example:
B4X:Dim j As String = $"{ data: { key1: value1, complex_key2: {key: value2} }, items: [0, 1, 2] }"$ Dim parser As JSONParser parser.Initialize(j) Dim m As Map = parser.NextObject Dim value1 As String = m.Get As Map("data").Get("key1") Dim value2 As String = m.Get As Map("data").Get As Map("complex_key2").Get("key") Dim FirstItemInList As String = m.Get As List("items").Get(0) For Each item As Int In m.Get As List("items") Log(item) Next
buttons.Get(2).CastTo(B4XView).Text = "less boring"
Dim value1 As String = m.Get As Map("data").Get("key1")
Dim value1 As String = (m.Get("data") As Map).Get("key1")
Dim value1 As String = ((Map) m.Get("data")).Get("key1")
Dim value1 As String = m.Get("data").CastTo(Map).Get("key1")
dim btn5 as B4XView = Buttons.Get(5)
dim btn2 as B4XView = Buttons.Get(2)
btn5.Text = btn2.Text
Buttons.Set(5,btn5) 'not really needed as btn5 already points to the instance in the list, but for arguments sake.
Buttons.Set As B4XView(5).Text = Buttons.Get As B4XView(2).Text
Buttons.Get As B4XView(5).Text = Buttons.Get As B4XView(2).Text
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?