Skip to content

Instantly share code, notes, and snippets.

@jkinkead
Created November 1, 2017 21:29
Show Gist options
  • Save jkinkead/26bf3b3d071b3277fb61eb8ff4be8829 to your computer and use it in GitHub Desktop.
Save jkinkead/26bf3b3d071b3277fb61eb8ff4be8829 to your computer and use it in GitHub Desktop.
struct UserLogin {
password: String,
username: String,
}
let loginInfo: UserLogin = getLoginFromEnvironment();
// These variable names must match the struct names for the short syntax.
let UserLogin { username, password } = loginInfo;
// You can rebind explicitly, if you want new names.
let UserLogin { username: myUsername, password: myPassword } = loginInfo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment