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

Add a capturing field sample #28

Merged
merged 1 commit into from Jun 30, 2021

Conversation

rinse
Copy link

@rinse rinse commented Jun 30, 2021

ラムダ式をfreezeするとそのラムダ式がキャプチャする変数も全てfreezeされる挙動の例に、その変数が参照型である場合を追加した。

参照型はきちんとディープコピーしないとInvalidMutabilityExceptionが起きることが分かった。
また、data classであってもcopyメソッドはshallow copyしかしないので、deep copyをきちんと行うようにしないと意図しないfreezeを引き起こすことが分かった。

@kdnakt kdnakt merged commit f62e22b into kdnakt:main Jun 30, 2021
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

Successfully merging this pull request may close these issues.

None yet

3 participants