Rob Napier on Nostr: There are some Swift features that are just a delight, and `some` in parameter types ...
There are some Swift features that are just a delight, and `some` in parameter types is one of them.
I was just working on a bunch of code where everything expects arrays. Totally reasonable. But I wanted to introduce `chunks(ofCount:)` to replace our home-grown `chunks(of:)`, and that makes things lazy and changes the types.
A few mechanical conversions of `[?]` to `some Sequence<?>`, and boom, more flexible without adding a ton of syntax noise.
Published at
2024-11-20 17:32:53 UTCEvent JSON
{
"id": "5c4b7f24ff5ba4bd0fbc9b0168b89b7d8b26a0ead24e138ea0ba7c557d26a957",
"pubkey": "c82850c78a83a4e6db428035a56e17dc4201863ee312550bd2d2351028582309",
"created_at": 1732123973,
"kind": 1,
"tags": [
[
"proxy",
"https://mastodon.social/@cocoaphony/113516476720648737",
"web"
],
[
"proxy",
"https://mastodon.social/users/cocoaphony/statuses/113516476720648737",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://mastodon.social/users/cocoaphony/statuses/113516476720648737",
"pink.momostr"
],
[
"-"
]
],
"content": "There are some Swift features that are just a delight, and `some` in parameter types is one of them.\n\nI was just working on a bunch of code where everything expects arrays. Totally reasonable. But I wanted to introduce `chunks(ofCount:)` to replace our home-grown `chunks(of:)`, and that makes things lazy and changes the types.\n\nA few mechanical conversions of `[?]` to `some Sequence\u003c?\u003e`, and boom, more flexible without adding a ton of syntax noise.",
"sig": "98d6f6852d4ed1e47cb29ba10ebc1e0a597d06668c5d12e8681b545fac53fe0bfa32abf9c548828a02b9a59ecc93ed41b7dff488b9e12ab6d6837412e81f7363"
}