New keyword - IsInitialized

Erel wrote in post #5

Note that it will eventually be IsNotInitialized due to name conflicts.
 
Thanks, I am aware of the Not operator. But if we try to make things easier, we might consider the common use cases first.
 
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:
Code:
If IsNotInitialized(Button1) = False Then Button.Text = "abc"
'or
If Not(IsNotInitialized(Button1)) Then ...
But we will need to get used to this
 
Maybe, just a suggestion drop the 'is' then code becomes

Code:
If NotInitialized(something) then ....
 
If NotInitialized(something) then ....
Double negation is stil possible, and also a very ugly
Code:
if Not(NotInizialized(something) then ..
 
But surely you would just use 'Else' if it was Initialised.
 
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.
 
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
 
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
 
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.
 
Back
Top