is is allowed to optionally mention type in swift ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

is is allowed to optionally mention type in swift ?

is there any optional way to declare the value type like java.. for example in typescript u can declare just using var or mention type too. can same thing happen in swift or no

29th Sep 2016, 8:41 PM
monire a.g
monire a.g - avatar
1 Answer
+ 2
Yes you can cause swift can guess and infer the type: var a = "swift" // later in code a = 10 // will cause an error.because a is a string and it's value was "swift" var b: Bool = false is the same as var b = false
3rd Oct 2016, 5:41 PM
Abdelkader Ait Assou
Abdelkader Ait Assou - avatar