![]() After your variable or constant name, you can add a colon and the type of data you expect this variable or constant to contain: var firstName: String = "Tom" We learned in the last lesson that we need the var keyword to declare new variables, or the let keyword for new constants: var firstName = "Tom"īut whether you’re declaring a variable or a constant, there is, in fact, an optional part of the declaration we left out. How to Specify the Data Type for your Variable or Constant However, they are the most common data types you will work with for a while. They are perfect for when there are only one of two options.īy no means are these the only data types in Swift.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |