ruby - What benefit does discriminating between local and global variables provide? -


i'm wondering benefit discriminating between local , global variables provides. seems me if made global variable, there lot less confusion.

wouldn't declaring global variable result in fewer errors because 1 wouldn't mistakenly call local variable in global instance, thereby encountering fewer errors?

where logic wrong on this?

some of boils down coding practices. keeping variables local means becomes simpler share code 1 application without having worry code conflicts. while simpler make global, getting habit of using global variables when have force code more efficiently , make code more structured.


Comments