Other B4A v10.50 is available for download

HAH

Well-Known Member
Licensed User
Thank you @Erel
I see this change in this release:
B4X:
Dim a as string="1234"
Dim b as object="1234"
'a=b >> False in this version
'a=b >> True in old version
Is this bug? or I'm wrong in coding!
 

LucaMs

Expert
Licensed User
Thank you @Erel
I see this change in this release:
B4X:
Dim a as string="1234"
Dim b as object="1234"
'a=b >> False in this version
'a=b >> True in old version
Is this bug? or I'm wrong in coding!
B4X:
    Dim a As String="1234"
    Dim b As Object="1234"
    If b = a Then
        Log("True")
    Else
        Log("False")
   End If
Write the object first
 

HAH

Well-Known Member
Licensed User
Write the object first
But I have many projects written & worked fine without taking care of object first !!
I don't want to re-write all previous codes of projects !!!
 

LucaMs

Expert
Licensed User
But I have many projects written & worked fine without taking care of object first !!
I don't want to re-write all previous codes of projects !!!
I think it has always been like this; it certainly hasn't changed in this new version.
 

agraham

Expert
Licensed User
Conditional comparison is done by casting the second item to the type of the first first, so to get a String comparison it should be if a = b then. In general when using an Object type in a comparison then it should be on the right as what is probably intended is a comparison of the type of the other (first parameter). This can also be important if you are comparing numeric values and String types, to get a numeric comparison the numeric type needs to be on the left or you may get unexpected results as String values may have leading or trailing zeroes.
 

HAH

Well-Known Member
Licensed User
Conditional comparison is done by casting the second item to the type of the first first, so to get a String comparison it should be if a = b then. In general when using an Object type in a comparison then it should be on the right as what is probably intended is a comparison of the type of the other (first parameter). This can also be important if you are comparing numeric values and String types, to get a numeric comparison the numeric type needs to be on the left or you may get unexpected results as String values may have leading or trailing zeroes.
That is means no hope with new version to compile my old projects containing this comparison in object=string manner!
So only solution is downgrade B4A to previous one! or revise all old projects code and change *impossible, I have large codes"
I hope this problem solved asap.
 

agraham

Expert
Licensed User
I don't think anything has changed with the compiler, I think it was always like that but a new warning was added as some people were getting puzzling comparison results.
If it was working before I would expect it to keep working now.
 

Jeffrey Cameron

Well-Known Member
Licensed User
That is means no hope with new version to compile my old projects containing this comparison in object=string manner!
So only solution is downgrade B4A to previous one! or revise all old projects code and change *impossible, I have large codes"
I hope this problem solved asap.
You are missing the point. All the IDE is doing new is warning you your code has the potential to fail, it is not doing anything differently that it always has. If it was working in prior versions properly it will continue to work properly in the new version. The order of comparison may not be significant if you are sure your object variable is of the same type you are comparing.

If it makes you feel better, just add
B4X:
    #IgnoreWarnings: 35
to your Activity Attributes section and/or modules.
 
Top