Could somebody please explain the following line:
var accountType: Account.Type = BitcoinAccount.self
In the book it is not explained.
Account.Type
BitcoinAccount.self
Thanks!
Could somebody please explain the following line:
var accountType: Account.Type = BitcoinAccount.self
In the book it is not explained.
Account.Type
BitcoinAccount.self
Thanks!
Hi @noah8610, the variable accountType is adopting the instance of the Account protocol. By using the colon with var accountType we are declaring the type to be the protocol Account. After declaring the type we are assigning the variable to BitcoinAccount.self which is then an expression of the BitcoinAccount class. By having accountType, we can then use it to set an initial amount and transfer amount with the account & transferAccount constants. Both constants are accessing the variable accountType.
Best,
Gina
This topic was automatically closed after 166 days. New replies are no longer allowed.