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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -