This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| struct User { | |
| var email: String | |
| var username: String | |
| } | |
| // Structs come with a prebuilt init function | |
| var user = User(email: "blue@gmail.com", username: "green") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| // Arrays | |
| // Most common type | |
| // Stores order | |
| let forecastTemp = [77, 32.3, 43.3] | |
| print("Day 1: \(forecastTemp[0])") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| var greeting = "Hello, playground" | |
| // Basic Math | |
| let num1 = 3 | |
| let num2 = 4 | |
| // add |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| // LOOPS can be used for ranges and arrays | |
| // example | |
| let ages = 1...6 | |
| for age in ages { | |
| print("Age \(age)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| // Functions | |
| func hi() { | |
| print("Hi") | |
| } | |
| hi(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| // Closures | |
| // You can assign functions to a variable in swift | |
| let work = { | |
| print("Working") | |
| } | |
| work() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| // You can pass a closure that requires a parameter | |
| func todo(items: [String], process: (String) -> Void) { | |
| for item in items { | |
| process(item) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| // Structs | |
| struct Music { | |
| var song: String | |
| let time: Int | |
| } | |
| var goodMusic = Music(song: "Blues", time: 33) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| // You can create our own initializer with structs | |
| struct Dog { | |
| var name: String | |
| var age = 0 | |
| init(name: String) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Header from './components/Header'; | |
| import Footer from './components/Footer'; | |
| import About from './components/About'; | |
| import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'; | |
| import { useState, useEffect } from 'react'; | |
| import Home from './components/Home'; | |
| function App() { | |
| const [tasks, setTasks] = useState([]); |