Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What happens if a variable name is same as an enum value? Can enum value be same as a variable name? #4

Open
Vishwajith-K opened this issue Apr 9, 2021 · 0 comments

Comments

@Vishwajith-K
Copy link
Owner

Ans - It depends. Rule - Whenever we try to access something, locals are checked first (afais-een). If enum value and variable are in same scope, then an error is guarantied. But they are in different scopes, then no (compiler) errors for this reason; but you may expect the unexpected behaviors; while coding you may think that you're trying to access a global variable or global enum value, it might have picked local enum value or variable with same name. To avoid this issue, enum are (most-ly 🤔) suffixed with _e in standard headers. Like in the case of datatypes being appended with _t.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant