Skip to content

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

Description

@Vishwajith-K

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions