Opened 10 years ago

Closed 10 years ago

#2434 closed Bug (No Bug)

Different behaviour between "=" and "=="

Reported by: anonymous Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:


It's different result when use "=" or "==" to compare string value with an integer number of 0:
Local $sTest = "test"
ConsoleWrite($sTest == 0) ; True
ConsoleWrite($sTest = 0) ;False

Attachments (0)

Change History (3)

comment:1 in reply to: ↑ description Changed 10 years ago by anonymous

Replying to anonymous:
Sorry, I made a mistake:

ConsoleWrite($sTest == 0) ; False
ConsoleWrite($sTest = 0) ; True

comment:2 Changed 10 years ago by Melba23

There is no bug.

Using the == operator converts both sides to strings and "test" is obviously not the same as "0".

However, the = operator does not do this - both sides are treated as numbers and Number("test") = 0. So 0 = 0 is true.


comment:3 Changed 10 years ago by Melba23

  • Resolution set to No Bug
  • Status changed from new to closed

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The ticket will remain with no owner.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.