Categories
|
Test: Swift - Type Inference, Type Safety, and Type Conversion 1. How do you convert length variable from Int to Double (named len)?
Results Congratulations! Correct Answer. You Answered: None. If you took the test, your answer will show up here. Correct Answer: var len = Double(length); var len: Double = Double(length); Explanation There is an initializer in Double struct that takes Int parameter and returns a Double value. B uses that format, where the type of len is inferred. D is same, but type of len is explicitly stated, which unnecessary and not recommended.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 1 of 5
Test is Based on this Article
This article talks about miscellaneous topics and concepts in Swift: Type Inference, Type Aliases, Type Safety, and Type Conversion
|
This is a test on Type Inference, Type Safety, and Type Conversion in Swift.
|
|
More Articles With Similar Tags
|
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 is a test on Type Inference, Type Safety, and Type Conversion in Swift.
|
|
|
|
|