New keyword - IsInitialized

Daestrum

Expert
Licensed User
Longtime User
Erel wrote in post #5

Note that it will eventually be IsNotInitialized due to name conflicts.
 

b4x-de

Active Member
Licensed User
Longtime User
Thanks, I am aware of the Not operator. But if we try to make things easier, we might consider the common use cases first.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Note that it will eventually be IsNotInitialized due to name conflicts.
That is indeed the case. IsNotInitialized does make sense. Similar to SQL IsNull.
I did prefer IsInitialized as it is a bit simpler to grasp as we can end with double negation with IsNotInitialized:
B4X:
If IsNotInitialized(Button1) = False Then Button.Text = "abc"
'or
If Not(IsNotInitialized(Button1)) Then ...
But we will need to get used to this
 

Daestrum

Expert
Licensed User
Longtime User
Maybe, just a suggestion drop the 'is' then code becomes

B4X:
If NotInitialized(something) then ....
 

udg

Expert
Licensed User
Longtime User
If NotInitialized(something) then ....
Double negation is stil possible, and also a very ugly
B4X:
if Not(NotInizialized(something) then ..
 

Daestrum

Expert
Licensed User
Longtime User
But surely you would just use 'Else' if it was Initialised.
 

udg

Expert
Licensed User
Longtime User
Sure. I was just pointing out a possible ugly syntax. Anyway I'm sure Erel will choose the form he believes will be easier and better for us. We will learn how best to use it ( knowing it'll be not mandatory) as we did in the past with other language innovations.
 

Sandman

Expert
Licensed User
Longtime User
Note that it will eventually be IsNotInitialized due to name conflicts.
About the name conflict, would it make a difference if you simply named it Initialized?

B4X:
If Not(Initialized(Lst)) Then Return
 

Spavlyuk

Active Member
Licensed User
Longtime User
What about making it similar to the C# is null syntax? Could avoid all the useless parentheses.

B4X:
If Variable Is Initialized Then Return
If Variable Is Not Initialized Then Return
 

MrKim

Well-Known Member
Licensed User
Longtime User
Interesting. I had a boolean variable called Initialized and the latest version of b4j didn't like it so I changed it to IsInitialized and it works fine But Maybe I should change it again.
 
Top