New feature - inline casting

Daestrum

Expert
Licensed User
Longtime User
I like the new way - far easier to comprehend.

If we write a library - do we supply the 'As' method and return valid conversions?
 

AnandGupta

Expert
Licensed User
Longtime User
Please anyone who knows of another forum where users often gets input of new upcoming features and can actually effect changes in that new feature before its final release, then please point me to that forum. I've never seen that happen on any other forums as usually the developers just release what they think is correct and their users just have to live with it.
Yes.

It is still true. For example, in HMG, users also contribute towards the development.
 

aeric

Expert
Licensed User
Longtime User
This reminds me of what I read a few days ago in another forum. There was a small war inside 😅
P.s I am wondering who is the OP
@alwaysbusy you made me almost drop my tears. The post is so touching when I read it. 😭
 

alwaysbusy

Expert
Licensed User
Longtime User
So instead of using the CastTo keyword, replacing it with As is much much shorter keystrokes and comfortable to my eyes and brain.
Yes, 'CastTo' sounds more complicated and may require some explanation of the inner workings. 'As' is more linguistic and natural. Good choice!
 

LucaMs

Expert
Licensed User
Longtime User
This reminds me
The first example reminds me of something I missed: typed lists.

With VB Net I could have:
B4X:
Dim lstButtons As New List(Of Button)
and then I could have written:
B4X:
lstButtons(3).Text = "Something"
with this inline casting I will be able to do it:
Buttons.Get(2).As(B4XView).Text = "abc"

[Yes, I could use an array of Buttons but a List is not an array, it is much more powerful.]
 

sorex

Expert
Licensed User
Longtime User
Yes, 'CastTo' sounds more complicated and may require some explanation of the inner workings.

for those who write queries/views in MSSQL this is something you do very often but you also don't need to know the inner workings of it as long as it works as intended.

got here by your tweet by the way, so thanks for mentioning this post as I didn't see it ;)

I like the second version of this feature. it means less declarations of variables if I see it right?
 

Heuristx

Active Member
Licensed User
Longtime User
The first example reminds me of something I missed: typed lists.

With VB Net I could have:
B4X:
Dim lstButtons As New List(Of Button)
and then I could have written:
B4X:
lstButtons(3).Text = "Something"
with this inline casting I will be able to do it:


[Yes, I could use an array of Buttons but a List is not an array, it is much more powerful.]

When I first looked at B4X, I was curious if I would miss generic lists and stuff like that.
But generic lists will not work when there are different object types in the same list. You can then set it to some superclass, and start DirectCasting, and it gets clumsy.
B4X is a great example of a language that is aggressively efficient and easy. Instead of figuring out what to use:
x = CStr(y)
or
x = Y.ToString
or
x = CType(x, String)
and so on, in B4X we just say
x = y
and that is powerful. Is it less typesafe? Not really, because when I write a = DirectCast(b, AClass) then I may have typed the wrong class mistakenly.
 
Top