All Computer Science Resources
Example Questions
Example Question #22 : Primitive Data Types
How do we declare a method to return a Double in Swift (iOS)?
Possible Answers:
func -> Double {}
func method() -> Double {}
func method -> Double {}
method() -> Double {}
Correct answer:
func method() -> Double {}
Explanation:
In Swift, all methods must first say what they are. They are functions, so they are prefixed with func. Next, methods must have a name. In this case, we named it method. All methods need to specify parameters, even if there are no parameters. So, method() i.e. no parameters. Finally, we wanted to return a Double. So we set the return type using -> Double.
Carlos
Certified Tutor
Certified Tutor
Pikes Peak Community College, Associate in Science, Cyber/Electronic Operations and Warfare.
All Computer Science Resources
Computer Science Tutors in Top Cities:
Atlanta Computer Science Tutors, Austin Computer Science Tutors, Boston Computer Science Tutors, Chicago Computer Science Tutors, Dallas Fort Worth Computer Science Tutors, Denver Computer Science Tutors, Houston Computer Science Tutors, Kansas City Computer Science Tutors, Los Angeles Computer Science Tutors, Miami Computer Science Tutors, New York City Computer Science Tutors, Philadelphia Computer Science Tutors, Phoenix Computer Science Tutors, San Diego Computer Science Tutors, San Francisco-Bay Area Computer Science Tutors, Seattle Computer Science Tutors, St. Louis Computer Science Tutors, Tucson Computer Science Tutors, Washington DC Computer Science Tutors
Popular Courses & Classes
MCAT Courses & Classes in Chicago, ISEE Courses & Classes in San Diego, GRE Courses & Classes in Washington DC, LSAT Courses & Classes in Miami, MCAT Courses & Classes in Los Angeles, SSAT Courses & Classes in San Francisco-Bay Area, Spanish Courses & Classes in Chicago, Spanish Courses & Classes in Boston, LSAT Courses & Classes in Los Angeles, SSAT Courses & Classes in Philadelphia
Popular Test Prep
SAT Test Prep in Atlanta, GRE Test Prep in Seattle, ISEE Test Prep in New York City, ACT Test Prep in Washington DC, LSAT Test Prep in Washington DC, GMAT Test Prep in San Francisco-Bay Area, ISEE Test Prep in Denver, SSAT Test Prep in Washington DC, GRE Test Prep in Atlanta, MCAT Test Prep in Atlanta