Skip to content
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

Fix typos: missing subscript parameters #81

Merged
merged 3 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,20 @@ extension OrderedDictionary.Elements.SubSequence {
extension OrderedDictionary.Elements.SubSequence {
/// Returns the index for the given key.
///
/// If the given key is found in the dictionary, this method returns an index
/// into the dictionary that corresponds with the key-value pair.
/// If the given key is found in the dictionary slice, this method returns an
/// index into the dictionary that corresponds with the key-value pair.
///
/// let countryCodes: OrderedDictionary = ["BR": "Brazil", "GH": "Ghana", "JP": "Japan"]
/// let index = countryCodes.index(forKey: "JP")
/// let slice = countryCodes.elements[1...]
/// let index = slice.index(forKey: "JP")
///
/// print("Country code for \(countryCodes[index!].value): '\(countryCodes[index!].key)'.")
/// print("Country code for \(countryCodes[offset: index!].value): '\(countryCodes[offset: index!].key)'.")
/// // Prints "Country code for Japan: 'JP'."
///
/// - Parameter key: The key to find in the dictionary.
/// - Parameter key: The key to find in the dictionary slice.
///
/// - Returns: The index for `key` and its associated value if `key` is in
/// the dictionary; otherwise, `nil`.
/// the dictionary slice; otherwise, `nil`.
///
/// - Complexity: Expected to be O(1) on average, if `Key` implements
/// high-quality hashing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ extension OrderedDictionary.Elements {
/// into the dictionary that corresponds with the key-value pair.
///
/// let countryCodes: OrderedDictionary = ["BR": "Brazil", "GH": "Ghana", "JP": "Japan"]
/// let index = countryCodes.index(forKey: "JP")
/// let index = countryCodes.elements.index(forKey: "JP")
///
/// print("Country code for \(countryCodes[index!].value): '\(countryCodes[index!].key)'.")
/// print("Country code for \(countryCodes[offset: index!].value): '\(countryCodes[offset: index!].key)'.")
/// // Prints "Country code for Japan: 'JP'."
///
/// - Parameter key: The key to find in the dictionary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ extension OrderedDictionary {
/// let countryCodes: OrderedDictionary = ["BR": "Brazil", "GH": "Ghana", "JP": "Japan"]
/// let index = countryCodes.index(forKey: "JP")
///
/// print("Country code for \(countryCodes[index!].value): '\(countryCodes[index!].key)'.")
/// print("Country code for \(countryCodes[offset: index!].value): '\(countryCodes[offset: index!].key)'.")
Copy link
Member

@lorentey lorentey Aug 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, this makes me wonder if we got our terminology right.

let index = countryCodes.index(forKey: "JP")!
print(countryCodes[offset: index].value)

Are we calling it an index, or an offset? 🤔

Maybe we should rename index(forKey:) to offset(ofKey:). Or change the subscript label to index? I'm not sure which would be better -- both seem a bit weird.

/// // Prints "Country code for Japan: 'JP'."
///
/// - Parameter key: The key to find in the dictionary.
Expand Down