Complete the code to declare a simple actor named Logger.
actor [1] { func log(message: String) { print(message) } }
In Swift, you declare an actor using the actor keyword followed by the actor's name.
Complete the code to declare an actor named DataStore with a property count initialized to 0.
actor DataStore {
var count: Int = [1]
}The property count is an integer and should be initialized with the number 0.
Fix the error in the actor declaration by completing the code.
actor [1] { func fetchData() async -> String { return "Data" } }
The actor name should be a simple identifier without keywords like func, class, or struct.
Fill both blanks to declare an actor named Counter with a method increment that increases count by 1.
actor [1] { var count = 0 func [2]() { count += 1 } }
The actor is named Counter and the method to increase count is named increment.
Fill all three blanks to declare an actor named BankAccount with a balance property and a method deposit that adds amount to balance.
actor [1] { var [2]: Double = 0.0 func [3](amount: Double) { balance += amount } }
The actor is BankAccount, the property is balance, and the method to add money is deposit.