{"action":"created","issue":{"url":"https://api.github.com/repos/hollance/swift-algorithm-club/issues/100","repository_url":"https://api.github.com/repos/hollance/swift-algorithm-club","labels_url":"https://api.github.com/repos/hollance/swift-algorithm-club/issues/100/labels{/name}","comments_url":"https://api.github.com/repos/hollance/swift-algorithm-club/issues/100/comments","events_url":"https://api.github.com/repos/hollance/swift-algorithm-club/issues/100/events","html_url":"https://github.com/hollance/swift-algorithm-club/issues/100","id":146121192,"number":100,"title":"typealias Element in the HashTable section","user":{"login":"joaopaulogalvao","id":4421962,"avatar_url":"https://avatars.githubusercontent.com/u/4421962?v=3","gravatar_id":"","url":"https://api.github.com/users/joaopaulogalvao","html_url":"https://github.com/joaopaulogalvao","followers_url":"https://api.github.com/users/joaopaulogalvao/followers","following_url":"https://api.github.com/users/joaopaulogalvao/following{/other_user}","gists_url":"https://api.github.com/users/joaopaulogalvao/gists{/gist_id}","starred_url":"https://api.github.com/users/joaopaulogalvao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joaopaulogalvao/subscriptions","organizations_url":"https://api.github.com/users/joaopaulogalvao/orgs","repos_url":"https://api.github.com/users/joaopaulogalvao/repos","events_url":"https://api.github.com/users/joaopaulogalvao/events{/privacy}","received_events_url":"https://api.github.com/users/joaopaulogalvao/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-05T22:18:40Z","updated_at":"2016-04-06T13:11:52Z","closed_at":"2016-04-06T13:11:52Z","body":"In the HashTable section, while applying it on a new project file, I noticed that `private typealias Element `, with uppercase E, in this part:\r\n\r\n```\r\npublic struct HashTable<Key: Hashable, Value> {\r\n  private typealias Element = (key: Key, value: Value)\r\n  private typealias Bucket = [Element]\r\n\r\n  private var buckets: [Bucket]\r\n  private(set) var count = 0\r\n\r\n  public init(capacity: Int) {\r\n    assert(capacity > 0)\r\n    buckets = .init(count: capacity, repeatedValue: [])\r\n  }\r\n\r\n  public var isEmpty: Bool {\r\n    return count == 0\r\n  }\r\n\r\n ...\r\n\r\n}\r\n```\r\nseems to be the same one used in the `for-loop` in the `updateValue` function here : \r\n\r\n```\r\npublic mutating func updateValue(value: Value, forKey key: Key) -> Value? {\r\n  let index = indexForKey(key)\r\n\r\n  // Do we already have this key in the bucket?\r\n  for (i, element) in buckets[index].enumerate() {\r\n    if element.key == key {\r\n      let oldValue = element.value\r\n      buckets[index][i].value = value\r\n      return oldValue\r\n    }\r\n  }\r\n       ...\r\n}\r\n```\r\nIt works fine on a couple of tests I tried, but is `element` referencing `Element` somehow? I could not get it. If it is a typo I can submit a pull request.\r\n\r\nThanks for this amazing source, it has been helping me a lot with my studies. "},"comment":{"url":"https://api.github.com/repos/hollance/swift-algorithm-club/issues/comments/206362604","html_url":"https://github.com/hollance/swift-algorithm-club/issues/100#issuecomment-206362604","issue_url":"https://api.github.com/repos/hollance/swift-algorithm-club/issues/100","id":206362604,"user":{"login":"joaopaulogalvao","id":4421962,"avatar_url":"https://avatars.githubusercontent.com/u/4421962?v=3","gravatar_id":"","url":"https://api.github.com/users/joaopaulogalvao","html_url":"https://github.com/joaopaulogalvao","followers_url":"https://api.github.com/users/joaopaulogalvao/followers","following_url":"https://api.github.com/users/joaopaulogalvao/following{/other_user}","gists_url":"https://api.github.com/users/joaopaulogalvao/gists{/gist_id}","starred_url":"https://api.github.com/users/joaopaulogalvao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joaopaulogalvao/subscriptions","organizations_url":"https://api.github.com/users/joaopaulogalvao/orgs","repos_url":"https://api.github.com/users/joaopaulogalvao/repos","events_url":"https://api.github.com/users/joaopaulogalvao/events{/privacy}","received_events_url":"https://api.github.com/users/joaopaulogalvao/received_events","type":"User","site_admin":false},"created_at":"2016-04-06T13:11:52Z","updated_at":"2016-04-06T13:11:52Z","body":"That is great, got it.\r\nThanks a lot for the explanation.\r\nI will go ahead and close this thread."}}