Different in Xcode 10

HUA YU TSENG
1 min readSep 19, 2018

--

Hello everyone, Xcode 10 has been officially released, There are couple different behavior between Xcode 9, for example enum’s hashValue and rawValue as following. In Xcode 9 all enums get a hashValue which is basically like an Index to the order in which the enums were declared, but in Xcode 10 the hashValue is not index of order anymore.

Xcode 10.0 enum:

//Xcode 10
enum myEnum: Int {
case apple
case banana
}
print(myEnum.apple.hashValue) //6301819286870297653
print(myEnum.banana.rawValue) //0
print(myEnum.banana.hashValue) //4559753696474043376
print(myEnum.banana.rawValue) //1

Xcode 9.4.1 enum:

Xcode 9.4.1
enum myEnum: Int {
case apple
case banana
}
print(myEnum.apple.hashValue) //0
print(myEnum.banana.rawValue) //1
print(myEnum.apple.hashValue) //0
print(myEnum.banana.rawValue) //1

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

HUA YU TSENG
HUA YU TSENG

Written by HUA YU TSENG

I am Red, an iOS developer, I have hands on experience in iOS, Flutter, familiar with RxSwift Moya Unit/UI testing and Gitlab-CI.

No responses yet

Write a response