Code – Part 4 Adding an item to an Array | Swift Programming Series

Download the file here: Tutorial.playground

Watch the full video here: https://youtu.be/8JK7vbLi_eU


Read the code below:

// Variables & Constants

let firstName = "Ben" // Constant

let lastName = "Tennyson"

let fullName = firstName + " " + lastName // String Concatenation

let interpolatedFullName = "My friend's name is \(firstName) \(lastName)" // String Interpolation

print(interpolatedFullName)

print(fullName)

var age = 16 // Variable

print("\(firstName) is \(age) years old!")

// Gives Error!! print(firstName + " is " + age + " years old!")

var profession = "Student"

print("\(fullName) is a \(age) year old \(profession)!")

// ------------------------------

// Collection Types

// 1. Arrays

// 2. Dictionaries

// 3. Sets

// Arrays

// let example = [9, 100, 81, 23]

var todo: [String] = ["Complete Homework", "Buy a Notebook", "Record Swift Tutorial"]

todo[0]

print(todo[1])

var friendList: [String] = ["John", "Joe"]

// First method to add item to an Array

friendList.append("Steve")

friendList

friendList[2]

// Second method to add item to an Array

17 June 2017

Hey guys! It’s another summer day today & the temperature outside is so much hot. It’s almost like fire 🔥! So I finished up one of my tuition & have another one after some time. Right now, I was just watching some Swift Programming Tutorials on YouTube & then I thought that lemme make a post on my new blog! So am I doing right now. Anyways, if you are reading this, do me a favor, just follow me on Instagram: https://www.instagram.com/rohantinna 😎

Hello, world!

So my new website is now up & running and if you are reading this you’re probably on my website so yeah! Feel free to make your way around my website & don’t forget to follow me on social platforms to always stay in touch!

 

Facebook [@rohantinnablog]: https://www.facebook.com/rohantinnablog

Instagram [@rohantinna]: https://www.instagram.com/rohantinna

Twitter [@rohantinna]: https://www.twitter.com/rohantinna

Snapchat [@rohantinna]: https://www.snapchat.com/add/rohantinna

Powered by WordPress.com.

Up ↑