Created
July 13, 2017 04:18
-
-
Save tranhieutt/5a17d0aa12524669faf379671f5dd5ba to your computer and use it in GitHub Desktop.
Swift coding convention
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
//Preferred: | |
if user.isHappy { | |
// Do something | |
} else { | |
// Do something else | |
} | |
//Not Preferred: | |
if user.isHappy | |
{ | |
// Do something | |
} | |
else { | |
// Do something else | |
} | |
//Use [:] | |
//Preferred: | |
class TestDatabase: Database { | |
var data: [String: CGFloat] = ["A": 1.2, "B": 3.2] | |
} | |
//Not Preferred: | |
class TestDatabase : Database { | |
var data :[String:CGFloat] = ["A" : 1.2, "B":3.2] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment