Undefined local variable or method ` ‘

Ever had this little nugget of information? Lets play spot the difference…

Example 1
def my_method(args) # :nodoc:

Example 2
def my_method(args) # :nodoc:

You will notice that there is no apparent difference, which is why I couldn’t work out why one line of code ran, and one caused an error. Anyway, to cut a long story short, I found a unicode character on the line that wasn’t working – and that unicode character didn’t have a corresponding variable or method!

So, Chris’ Thursday Tip is to turn on invisible characters in TextMate (View -> Show Invisibles ⌥⌘I).

Advertisements