Debugging Enhancement: Suggesting the use of "is"


#1

I’ve been beating my head against a wall on a level for about half an hour because I forgot that you use “is” instead of “equals” when comparing strings.

I realize I can be kinda dense on these things. However, it would be great if, when the debugger sees a user using an “=” to compare a value to a string (i.e. anything in quotes) that it would helpfully suggest something like this:

Reminder: To compare the values of strings, you need to use "is" not "=".
          (ex: if enemy.type is "thrower")

Alternately, it might make sense to add this into the comments on the first few levels where you are doing string comparisons (if it isn’t there already). It’s especially helpful from those of us coming from languages where “=” works for these sorts of comparisons.


#2

You are talking about coffeescript specifically right?


#3

Hmm; == and is should work the same on strings in all the languages we support. But = is the assignment operator, not the equality operator, in most of the languages. Is that the problem–that it wasn’t giving you a warning about using =? Or that == has a bug in it?


#4

strange. i didn’t think is worked in native javascript?


#5

Ah yeah, right, is doesn’t work in JavaScript (use ===). I meant that if is exists, it works the same as == for equality comparisons on strings. is is available in Python and CoffeeScript.


#6

Sorry, for failing to reply, I’ve been away on business. The problem was I was using “=” versus “==”. So the overall debugging issue remains. I think most novices/newbies will forget that “=” is different than “==”.

Perhaps there could be a sort of FAQ (or FoB “Frequently Occuring Bugs”) style check list with an entry like, did you “accidentally use ‘=’ instead of ‘==’?”


#7

Hmm, I thought that it DID give warnings about: “if var = something” but it doesn’t (anymore?) at least not in python.