Skip to content

Instantly share code, notes, and snippets.

@smosko
Created October 17, 2021 14:21

Revisions

  1. smosko created this gist Oct 17, 2021.
    5 changes: 5 additions & 0 deletions String+hashCode.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    extension String {
    func hashCode() -> Int32 {
    unicodeScalars.map { Int32($0.value) }.reduce(0) { 31 &* $0 &+ $1 }
    }
    }