Created
June 26, 2017 04:21
-
-
Save ezura/2ff6d3f8e84f6f51f72917abc499f0bb to your computer and use it in GitHub Desktop.
kotlin での optional のやつ見て思ったこと。エラーメッセージしっかりしててくれた。「inout つけた場合に"書き換え(in)"も許可する必要があるので不変じゃないといけなくなる」という認識であってるかな…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func f(_ v: Any?) {} | |
| func f_inout(_ v: inout Any?) { /* v = nil */ } | |
| var v: Any = 1 | |
| // OK | |
| f(v) | |
| // ❗️error: cannot pass immutable value as inout argument: implicit conversion from 'Any' to 'Any?' requires a temporary | |
| //f_inout(&v) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment