Apple invented a language called swift in 2014. So it’s a pretty new one and includes many good merits from other languages. Basically, its grammer is very similar to JavaScript. The nice part is swift introduces “struc“ that groups relevant data. And its IDE Xcode provide immediate feedback.
I am not interesting in developing a game now. But it’s good to know it.
learning sources:
support both inferred typing and explicit typing
Once the type is declared or set, it can’t change.
var mylove = “w” //inferred typing, will guess it as string
var mylove: Character =”w”//explicit typing
var islove: Bool = true
var secretNumber = 7
var price: Double = 2.50
let pi = 3.14 //constant
Naming
keyword:
var, let, class, import, private, operator.
Hungarian Notation:
`intNumberOfLivescountNumberOfLivessumTotalScore
Camel Casing:
totalCumulativeScoresecondsSinceLastUpdateminutesTillLaunch
Naming constant:
PointsPerLifeDefaultGreetingMaxLengthPOINTS_PER_LIFEDEFAULT_GREETINGMAX_LENGTH
name for a struct a capital letter:
struct Student {
let name: String
var age: Int
var school: String
}
var ayush = Student(name: "Ayush Saraswat", age: 19, school: "Udacity")
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.