8 Replies
      Latest reply on Aug 20, 2017 12:30 PM by Claude31
      John368 Level 1 Level 1 (0 points)

        Tell the new, I created the class, at the same time I want to do without the initializer. So I just set the start values and, according to Swift, it should type the type himself, it do not show errors. Then I create an instance of the class, assign values to variables, and get an error. I can not understand why

         

         

        class Account {
            var capital = 0.0
            var rate = 0.0
          
            var profit: Double {
              
                get {
                    return capital + capital * rate
                }
                set(newProfit) {
                    self.capital = newProfit / (1 + rate)
                }
            }  
        }
        
        
        var myAcc = Account (capital: 1000.0, rate: 0.1)
        
        

         

        Last line gives an error that - argument passed to call that takes no arguments var myAcc = Account (capital: 1000.0, rate: 0.1)