+ 3

Can you have an object have the same name as a variable?

14th Jun 2018, 11:07 PM
Kuyann
8 odpowiedzi
+ 3
the better question is probably "should you have an object with the same name as a variable" lol. to keep things legible and to manage future confusion, probably best to make distinct names if possible.
14th Jun 2018, 11:56 PM
Leondra Gonzalez
Leondra Gonzalez - avatar
+ 3
The answer varies depending on which language are you working on
15th Jun 2018, 11:15 AM
Abhinav Agarwal
Abhinav Agarwal - avatar
+ 2
Depending on the language, an object is a type of variable, just like integers, arrays etc are. But the same is not so for key words.
14th Jun 2018, 11:29 PM
Andre Daniel
Andre Daniel - avatar
+ 2
thank you for your help
15th Jun 2018, 12:11 AM
Kuyann
+ 2
i appreciate it
15th Jun 2018, 12:11 AM
Kuyann
+ 2
That would be based on the language you are working on. You can and cannot. But avoid any form of confusion and to improve readability of your codes; I'd advice you make 'em distinct.
15th Jun 2018, 3:15 PM
Israel Emmanuel
Israel Emmanuel - avatar
+ 1
so if you use a case sensitive language and just change the case it would still work
15th Jun 2018, 12:10 AM
Kuyann