The hash
property of a string returns an unsigned integer that can be used as a hash address.
string.hash
This value returns an unsigned integer value.
Let’s look at the code below:
// import Foundationimport Foundation// create string valueslet name = "Edpresso"let role = "Learning Platform"let author = "Theodore"let badge = "Gold"// get hash and print resultsprint(name.hash)print(role.hash)print(author.hash)print(badge.hash)
Foundation
framework. It allows us to access a String instance’s hash
property and lots more.hash
property and the results are printed to the console.