Skip to content

Instantly share code, notes, and snippets.

@Gabbrolee
Created August 3, 2021 17:58
Show Gist options
  • Save Gabbrolee/9a37f75f301144a05479632d28805044 to your computer and use it in GitHub Desktop.
Save Gabbrolee/9a37f75f301144a05479632d28805044 to your computer and use it in GitHub Desktop.
DAY ONE: DATATYPES
//MARKS:- TYPES OF DATA
// 1. String : they are combination of characters and it could be of million characters as the case maybe
// string declaration
var country = "Nigeria" //first method is type inference: is when //swift assing a datatype to variable or //constant base on the type of value assign //to the variable
var nation: String //second method is type annotation method
nation = "Nigeria"
//2. Integer: they are positive whole numbers
var age: Int
age = 25
//MARKS:- type safety is observe in swift and it simply means swift will not allow one to put values in a variable declared as Int into string variable
//age = "James Bond" /* swift will throw up error since age has been declared as an integer initially */
//3. FLOAT AND DOUBLE: these are use for decimal numbers and double is prefer to float because it holds more accuracy than float that is it can take more fractional digit than float
var latitude : Double
latitude = 36.1666677888 //36.1666677888 more accuracy
var longitude : Float
longitude = 36.1666677888 // 36.16667 less accuracy
//4. BOOLEAN: this is a data type that helps to set value to true, false or absolute
// Declaring variable as a boolean
var stayOutTooLate: Bool
stayOutTooLate = true
// it can also be declare this way
var comeHomeTooLate: Bool = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment