9.1.1. Functions (methods) inside structs
struct Person{
var name:String
var age:Int
var city:String
// computed property .....
var isMinor:Bool{
if age < 18{
return true
}else{
return false
}
}
// method printProfile...
func printProfile(){
print(
"""
Hi! I am \(name).
I am \(age) years old.
And I live in \(city)!
Happy coding!
"""
)
}
}Struct initializers
Source code
Last updated