Modify

#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, on Aug 28, 2013 at 7:24:40 AM

Replying to anonymous:
Sorry, I made a mistake:

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

comment:2 by Melba23, on Aug 29, 2013 at 5:59:01 PM

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, on Aug 29, 2013 at 6:00:38 PM

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.