Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- class Person{
- var name = ""
- }
- class BlogPost {
- var fullTitle:String{
- if title != nil && author != nil {
- return title! + " by " + author!.name
- }
- else{
- return "No Title"
- }
- }
- var title:String? //This is defined as NIL. The string is empty
- var body:String = "Welcome"
- var author:Person? //empty
- var numberOfComments:Int = 0
- }
- let author = Person()
- author.name = "Shihab"
- let myPost = BlogPost()
- myPost.author = author
- myPost.title = "Swift for beginners"
- print(myPost.fullTitle)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement