Last active
March 13, 2018 07:26
-
-
Save vialyx/d04678b23e3cdbd4ef91ec68cbd1a535 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let admins = [User(name: "Admin")] | |
// [{name "Admin"}] | |
let guests = [User(name: "Guest")] | |
// [{name "Guest"}] | |
var allUsers = admins + guests | |
// [{name "Admin"}, {name "Guest"}] | |
// TODO: - Use .isEmpty instead of .count | |
if allUsers.isEmpty { | |
print("User list is empty") | |
} else { | |
// TODO: - Use subscript functionality | |
let user = allUsers[0] | |
// OR | |
// user = allUsers.first | |
print("First user is: \(user)") | |
// First user is: User(name: "Admin")\n | |
} | |
// TODO: - Subscript syntax for range | |
allUsers[0...1] = [User(name: ""), User(name: "")] | |
// [{name ""}, {name ""}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment