Skip to content

Discussion: variables const by default  #25

Closed
@dkaszews

Description

@dkaszews

Have you considered making variables const by default? I have seen it float around as a recommendation and personally am of the "const everything" camp. It encourages more careful code, catches many errors and makes it more readable (if I see same variable later down the line, I know it has the same value, don't need to check every line in between).

a: int = 3;
a = 5;  // error! implicit const

b: mutable int = 3;
b = 5;  // fine

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions