0
What are anotations? Never heard of then in swift?
Can someone explain more in detail?
2 Antworten
+ 1
The process of defining variable type explicitly in swift is called as annotations
example:
var a: String = "welcome"
Here we are declaring the variable "a" as string external, this is called as annotations.
It in not needed to define the variable type explicitly every time. Swift has a type inference mechanism by which it Atto detect the type of the variables
example:
we can write the above statement as
var a = "welcome"
here the swift will assign the variable type "a" as string automatically.
0
It is also important to note that always there should be some way to detect the type of the variable, otherwise you will be getting error.
example:
if you are declaring the above statement simply as
var a
without specific the type or assigning some value then you will be getting error message