Browse Questions
- async let starts a child task immediately and lets you await its result later.
- Identifiable requires a type to have a unique id property.
- A race condition occurs when two or more threads access shared mutable state simultaneously, producing unpredictable results depending on timing.
- Secure Comparator is a zero-knowledge protocol that lets two parties confirm they hold the same secret without either side transmitting it, or leaking anything usable when the secrets differ.
Answer:
async let starts a child task immediately and lets you await its result later. It's the cleanest way to run a fixed number of async operations in parallel.
Code Example:
// Sequential — slow (waits for each one)
func loadDashboard() async throws -> Dashboard {
let user = try await fetchUser() // waits
let posts = try await fetchPosts() // then waits
let notifications = try await fetchNotifications() // then waits
return Dashboard(user: user, posts: posts, notifications: notifications)
}
// Parallel with async let — all three start at the same time
func loadDashboard() async throws -> Dashboard {
async let user = fetchUser()
async let posts = fetchPosts()
async let notifications = fetchNotifications()
return try await Dashboard(
user: user,
posts: posts,
notifications: notifications
)
}
Rule of thumb: Use async let for a fixed set of concurrent operations. Use TaskGroup for a dynamic number.