Skip to content

Clarify HTTPFields name subscript get/set semantics - #131

Open
ZayanKhan-12 wants to merge 1 commit into
apple:mainfrom
ZayanKhan-12:docs/clarify-fields-subscript
Open

Clarify HTTPFields name subscript get/set semantics#131
ZayanKhan-12 wants to merge 1 commit into
apple:mainfrom
ZayanKhan-12:docs/clarify-fields-subscript

Conversation

@ZayanKhan-12

Copy link
Copy Markdown

Motivation

Resolves the confusion in #94. The doc comment on subscript(_: HTTPField.Name) says "If multiple fields with the same name exist, they are concatenated with commas…" without stating that this describes only the getter. As #94 shows, it can be read as the setter appending a field per assignment — when the setter actually replaces all existing fields with that name (and nil removes them), as @guoye-zhang clarified in that issue.

Modifications

Split the behavior description into explicit "when reading" / "when setting" sentences and cross-reference subscript(values:) for setting multi-value fields. Documentation-only; no code changes.

Result

The subscript's replace-on-set semantics are stated where users first look, closing the gap that prompted #94.

🤖 Generated with Claude Code

The doc comment said "If multiple fields with the same name exist, they
are concatenated with commas", without saying it describes only the
getter. It was read as the setter appending fields (apple#94), when the
setter actually replaces all fields with the name. Document the getter
and setter behaviors separately and point at subscript(values:) for
setting multiple fields.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant