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

Copies of constant objects should be modifiable. #38

Closed
skx opened this issue Sep 30, 2018 · 0 comments
Closed

Copies of constant objects should be modifiable. #38

skx opened this issue Sep 30, 2018 · 0 comments
Assignees

Comments

@skx
Copy link
Owner

skx commented Sep 30, 2018

This code fails:

 let a = PI;
 let a = a.to_i();
 > Error: Attempting to modify 'a' denied; it was defined as a constant.

However this works:

let a = PI;
puts( a.to_i() );

The reason for this is the assignment-operation copies the const-value of the source variable (PI in this case).

@skx skx self-assigned this Sep 30, 2018
@skx skx closed this as completed in 329ea75 Oct 1, 2018
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