Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

Swift convenience Initializer

class University {
   var name : String
  var rank : String
  
  init(name : String, rank: String) {
    self.name = name
    self.rank = rank
  }

  // define convenience init  
  convenience init() {
    self.init(name: "Kathmandu University", rank: "1st")
  }
  
}

var university1 = University()
print(university1.name)
print("Rank:", university1.rank)
Comment

Swift convenience Initializer

class University {
  
  var name : String
  var rank : String
  
  init(name : String, rank: String) {
    self.name = name
    self.rank = rank
  }

  // define convenience init  
  convenience init() {
    self.init(name: "Kathmandu University", rank: "1st")
  }
  
}

var university1 = University()
print(university1.name)
print("Rank:", university1.rank)
Comment

PREVIOUS NEXT
Code Example
Swift :: swift output 
Swift :: Swift Nested Ternary Operators 
Swift :: Swift Iterate Over a Set 
Swift :: Closure as function parameter 
Swift :: Swift Optional Binding (if-let 
Swift :: xcode create image from calayer 
Swift :: Swift Access Elements from Dictionary 
Swift :: swift constants 
Swift :: how to have diffrent size images in a stack view swift 
Swift :: swift concurrency datatask before ios 15 
Swift :: Swift guard with multiple conditions 
Swift :: protocol oriented programming swift github Basic 
Swift :: Swift Modify Tuple Element 
Swift :: Swift Check if two sets are equal 
Swift :: swift loop site:stackoverflow.com 
Swift :: Swift Add Elements to a Dictionary 
Swift :: ios network request 
Swift :: how to figure out ios vesion swift 
Ruby :: how to check if data is an array or not ruby 
Ruby :: ruby measure time 
Ruby :: ruby memory location 
Ruby :: rspec add support folder to gem 
Ruby :: add timezone in rails 
Ruby :: table name from rails console 
Ruby :: ruby how to loop through an array 
Ruby :: ruby find method 
Ruby :: rails send email from console 
Ruby :: ruby string trmi 
Ruby :: how to use multiple ruby version in mac as per project 
Ruby :: ruby includethis or that 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =