Skip to content

replace const with let in reference examples #3877

@stalgiag

Description

@stalgiag

Hi all, this is in no way urgent but just wanted to open an issue to discuss the usage of const for mutable assign-by-reference variables.

This can be seen in a number of places, here for example or here. This isn't always the case as seen here.

This is technically okay since the immutable part of an assign-by-reference variable is the reference and the data is able to change. A clear explanation is available here.

Though it is technically okay, I personally feel that it is little more clear to only use const for declaring variables that will not be modified within the scope of that variable. If the data connected to a variable will be changed through use of that variable then it should be declared with let.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions