Categories
|
Test: Swift - Variables and Constants 4. Which of the following statements produce an error?
Results Congratulations! Correct Answer. You Answered: None. If you took the test, your answer will show up here. Correct Answer: let name: Int = “infiniteZest.com" Explanation First statement declares name as an integer (Int) and then assign a string value to it. Swift is big on code safety (type safety) - an object of a different type cannot be assigned without proper conversion. And, with B, no type is specified and Swift has no way of inferring the type.Take the Test Take the complete test on this topic. You will be able to review answers to questions and get a test score.
Take the Test
Question 4 of 6
Test is Based on this Article
This article talks about variables and constants and how Swift forces you to choose var (a variable) or let (a constant) right at the time of declaration.
|
Test on variables (var) and constants (let) in Swift
|
|
More Articles With Similar Tags
|
Test on variables (var) and constants (let) in Swift
|
This series of articles goes through the basics of Swift. It introduces Playgrounds and REPL; Variables and Constants; Int, Float, Bool; Tuples, Type Aliases, Type Inference, Type Safety, and more.
|
This article discusses the boolean types in Swift and contrasts with how these types are used in C and Objective-C.
|
Test on Boolean Types in Swift.
|
Test on comments, structured comments, and markup in Swift
|
|
|
|
|