Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I set a var or constant to a specific type in swift

I am very new to swift and I wanted to know about how to set a variable or constant to a specific type

I had some problems with just adding
var myVar = Date()

can anyone help

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

welcome to stackoverflow

To set a constant or variable to a specific type, use this.

Variables:

var currentDate:Date = Date()

Constants:

let currentDate:Date = Date()

you need to add that colon and then the type

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading