-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix example snippet in Array.swift #34146
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
base: main
Are you sure you want to change the base?
Conversation
Note that this file is talking about bridging as it applies to Darwin's Foundation. If write(to:) has a behavior you don't like, you will need to file behavior change requests not with Swift, but with Apple at https://feedbackassistant.apple.com/. |
117ffcb
to
3b9c0b3
Compare
3b9c0b3
to
d32a993
Compare
@natecook1000, @amartini51 could you please have a look? |
The documentation for Has the bridging behavior changed also? The new discussion (which has some English usage problems we can fix later) tells a different story with regard to optionals. |
/// values are bridged as `NSNull`. Therefore `moreColors` could be bridged | ||
/// to `NSArray` as well. Because `write(to:)` method throws exception if it | ||
/// encounters `NSNull` values, `do catch` should be used to check if write | ||
/// succeeded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior of write(to:)
belongs on that symbol's reference, we don't need to repeat it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I just keep fix write(to:atomically:)
=> write(to:)
removing everything else added to this doc comment?
It not about |
Yes, bringing behaviour have changed. Original snippet claims it should be compile error. But snippets compiles without errors and runs without errors. Original snippet could not be left untouched because it tells wrong story. |
@amartini51 ping |
Should we proceed with this PR or should I close it? |
Fix example snippet in Array.swift
Example snippet has several problems:
it uses deprecated function
write(to:atomically:)
snippet and explanation claim bridging
[String?]
toNSArray
is compile error when it's not - bridging works fine, butwrite(to:atomically:)
function fails. Despite retuned fail andtrue
atomically
parameter, function writes elements into file until firstNSNull
and keeps this file in file system. Probably it's another problem which should be filed. cc: @millenomiThis PR uses
write(to:)
instead of deprecatedwrite(to:atomically:)
in example, addsdo catch
and changes explanation preceding example. I feel that this explanation should be improved. Help is appreciated.