What are anotations? Never heard of then in swift? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What are anotations? Never heard of then in swift?

Can someone explain more in detail?

6th Aug 2016, 9:24 PM
Moe Slim
Moe Slim - avatar
2 Answers
+ 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.
7th Aug 2016, 3:58 AM
ragu raman
ragu raman - avatar
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
7th Aug 2016, 4:05 AM
ragu raman
ragu raman - avatar