I am strugeling to work with the array accounts, I don't really know how I should handle it, how I should initialize it in order to correctly append the object accountFromJohn to the list accounts.
class Bank {
var bicCode : String
var address : String
var customer : Customer
var accounts : [BankAccount] = []
init(bicCode : String, address : String, customer : Customer) {
self.bicCode = bicCode
self.address = address
self.customer = customer
}
}
var accountFromJohn = BankAccount(accountNumber : 192, balance : 20, customer : John)
var ING = Bank(bicCode : "LUING18", address : "Avenue du Swing", customer : Paul)
ING.accounts.append(accountFromJohn)
print(ING.accounts) // output : [main.BankAccount] ; wanted output : [accountFromJohn]
Best Reagars, Thanks in advance.
accountFromJohnis a variable name. Variable names exist purely for human interpretation, and don't exist at all at runtime. TheBankAccountinstance that's calledaccountFromJohnis actually some memory address, or some set of CPU registers. The program is telling you thatING.accountscontains one instance of typemain.BankAccount. It doesn't know anything about whether you choose to call that instanceaccountFromJohnormagicUnicornRainbowPoops.