After my second app, I *really* miss my for each loops...
Example 2: with casting built in
I know is the same as for:
But it's much cleaner though, and saves much typing, typos etc... not to mention that the x variable becomes the object we're getting rather than doing a get(x) with some decralaration...
Most of the time in other vb languages we solely use for each, unless we're grabbing things in the middle which isn't too often for most day to day stuff. It's just one of those little things that we would really use in every project multiple times...
B4X:
Dim arr(4) as string
For Each x in arr
'Do something with x directly since it's already the object we wanted.
Next
Example 2: with casting built in
B4X:
Dim arr(4) as object
For Each x as SOME_TYPE in arr
'Do something with x directly since it's already the object we wanted, of the type SOME_TYPE.
'I believe this would even make it easier to keep intellisense working properly.
Next
I know is the same as for:
B4X:
For x = 0 to arr.length-1
Dim obj = arr(x)
'Do something with obj
Next
But it's much cleaner though, and saves much typing, typos etc... not to mention that the x variable becomes the object we're getting rather than doing a get(x) with some decralaration...
Most of the time in other vb languages we solely use for each, unless we're grabbing things in the middle which isn't too often for most day to day stuff. It's just one of those little things that we would really use in every project multiple times...
Last edited: