Closed ktprograms closed 1 year ago
It might read better to shorten the six lines for items
into one through nil coalescing
@anohren I can't see how that's possible, since it'd be of different types.
As long as the type annotation is [Any]
the types should all be inferred as Any
. Does that not work?
let items: [Any] = [ URL(string: url) ?? url ]
Diff e6f0a45...6c30d67: Use nil coalescing for creating share item Thanks @anohren
On Fri Jul 8, 2022 at 9:51 AM +08, anohren wrote:
As long as the type annotation is
[Any]
the types should all be inferred asAny
. Does that not work?let items: [Any] = [ URL(string: url) ?? url ]
Ah, Thanks! Didn't know it worked like that.
-- Reply to this email directly or view it on GitHub: https://github.com/OdyseeTeam/odysee-ios/pull/345#issuecomment-1178448652 You are receiving this because you authored the thread.
Message ID: @.***>
No problem!
You can think of it as equivalent to e.g:
let s: String? = "a non-optional string"
let e: MyProtocol = MyConformer()
where the compiler knows to wrap your string in Optional.some
, and to turn your value into the existential any MyProtocol
only from reading your type annotations.
Allows using URL-specific share sheet actions.
Fix: #325