WaterNotWords
WaterNotWords

Reputation: 1007

What is the Swift 2+ equivalent of this one line of code

What is the Swift 2+ equivalent for this line of code found in this answer?.

 let a:UInt16 = UInt16(bytes[0]) * 256 + UInt16(bytes[1])  

Upvotes: 1

Views: 105

Answers (1)

Bhavin Bhadani
Bhavin Bhadani

Reputation: 22374

by checking that link .. first you have to define bytes array like [UInt8]

   let bytes:[UInt8] = [0x01, 0x02]
   let a = UInt16(bytes[0]) * 256 + UInt16(bytes[1])

Upvotes: 3

Related Questions