Page 150

Swift

self.tuesday = tuesday }

init(daysofaweek: Int) { sunday = daysofaweek monday = daysofaweek tuesday = daysofaweek } }

let week = Days(sunday: 1, monday: 2, tuesday: 3) println("Days of a Week is: \(week.sunday)") println("Days of a Week is: \(week.monday)") println("Days of a Week is: \(week.tuesday)")

let weekdays = Days(daysofaweek: 4) println("Days of a Week is: \(weekdays.sunday)") println("Days of a Week is: \(weekdays.monday)") println("Days of a Week is: \(weekdays.tuesday)") When we run the above program using playground, we get the following result: Days of a Week is: 1 Days of a Week is: 2 Days of a Week is: 3 Days of a Week is: 4 Days of a Week is: 4 Days of a Week is: 4

Parameters without External Names When an external name is not needed for an initialize underscore '_' is used to override the default behavior. struct Rectangle { var length: Double

init(frombreadth breadth: Double) { 138

​Fast is really a strong and intuitive coding language for macOS, iOS, watchOS and tvOS....  

Quick is a effective and instinctive programming language for macOS, iOS, watchOS and tvOS....

Read more
Read more
Similar to
Popular now
Just for you