Modify

Opened 6 years ago

Closed 6 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)

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

Replying to anonymous:
Sorry, I made a mistake:

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

comment:2 Changed 6 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.

M23

comment:3 Changed 6 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

Action
as closed The ticket will remain with no owner.
Author


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

 
Note: See TracTickets for help on using tickets.