TL;DR: Use var for properties in struct as long as it serves as a nominal tuple. In most cases, there is no obvious benefit to using let for struct properties.
Let's start with a simple example:
struct MyStruct {| import * as admin from 'firebase-admin'; | |
| admin.initializeApp({ | |
| credential: admin.credential.cert(__dirname + 'YOUR_KEY_RELATIVE_PATH'), | |
| databaseURL: 'https://YOUR_PROJECT_ID.firebaseio.com', | |
| }); | |
| const sleep = (msec: number) => new Promise(resolve => setTimeout(resolve, msec)); | |
| (async () => { |
Author: Chris Lattner
Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.
This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.
以下転載: