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

Copy Trait documentation is incorrect #1

Open
shadowhand opened this issue Apr 20, 2017 · 1 comment
Open

Copy Trait documentation is incorrect #1

shadowhand opened this issue Apr 20, 2017 · 1 comment

Comments

@shadowhand
Copy link

The following statement is incorrect:

2nd - you have to make changed field public because when you clone $this and try to modify some field you don't have an access to private and protected fields anymore. Leaving those fields with such liberal property visibility may lead to a lot of troubles.

Cloning an object does not change its scope. Thus, modifying a clone inside of the parent is perfectly valid and possible.

@shadowhand
Copy link
Author

My recommendation would be to drop the Copy trait entirely. It has limited value and potentially exposes the ability to modify objects that are not intended to be modified, due to copy being a public method.

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