{infiniteZest}
// Articles. Tutorials. Utilities.
Home  |   Search  |   Login  
Categories Skip Navigation Links
New / All
AJAX
Apple
ASP.NET
.NET
Git
Google / Android
Python / IronPython
Miscellaneous
SQL Server
Test: Swift - The Implementation of Optionals

4. var score = Optional(); print(score) — what does this print in Swift?




Results
Congratulations! Correct Answer.
You Answered: None. If you took the test, your answer will show up here.
Looking for the following phrases: nil (your answer might be correct even without these phrases)
Explanation
The line var score = Optional() is same as var score: Int? — The value here is being initialized to nil (a no-value state). Hence the print function will print nil.
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 5


Test is Based on this Article
icon-swift-article.jpg
This article discusses how Optionals are implemented in Swift.
icon-swift-test.jpg
Test on how Optionals are implemented internally in Swift.

More Articles With Similar Tags
icon-swift-test.jpg
Test on how Optionals are implemented internally in Swift.
icon-swift-article.jpg
This article talks about unwrapping the optionals in Swift implicitly and the circumstances where you would use this functionality.
icon-swift-article.jpg
This article discusses the safer ways of unwrapping an optional in Swift that includes Optional Binding.
icon-swift-article.jpg
This article talks about the Nil Coalescing Operator (??) in Swift.
icon-swift-article.jpg
This article talks about optional chaining in swift where multiple optionals can be chained together and fail gracefully by returning nil when one of them is nil.
                                                                                                                                                                                                             
About  Contact  Privacy Policy  Site Map