ruby - undefined local variable or method ` ' for main:Object -
ruby - undefined local variable or method ` ' for main:Object -
sometimes, next causes unusual bug:
> nil || 4 nameerror: undefined local variable or method ` 4' main:object > nil || [] nameerror: undefined local variable or method ` ' main:object
what reason?
you accidentally typing alt + space on mac, produces non-breaking space. ruby not consider whitespace, part of variable name. complains variable not exist.
some people remap alt + space space in order prevent typo.
i highlight invisible characters in text editor, notice typo immediately.
ruby whitespace
Comments
Post a Comment