Question:

What output will be produced by the code below?

let oneMillion = 1_000_000
let oneThousand = oneMillion / 0_1_0_0_0
print(oneThousand)

Answer:

Correct answer: 1000.

Explanation: Swift allows you to use any number of leading zeroes before a number, and any number of underscores inside a number, in order to make reading easier. The example given, 0_1_0_0_0, is unlikely, but a perfectly valid way to write 1000.


Keywords:

© 2017 QuizBucket.org