Modify

Opened 13 years ago

Closed 13 years ago

#2434 closed Bug (No Bug)

Different behaviour between "=" and "=="

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

Description

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)

in reply to:  description comment:1 by anonymous, 13 years ago

Replying to anonymous:
Sorry, I made a mistake:

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

comment:2 by Melba23, 13 years ago

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.

M23

comment:3 by Melba23, 13 years ago

Resolution: No Bug
Status: newclosed

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.