Beginner Swift Flashcards
Property of an array that counts the number of items in a given array.
Var.count
What is an array?
A sequential list of variables. Always starts at 0, increments by one in order.
Var todo[string] = [“call”,”suck”]
To add a value on end:
todo += [“swallow”]
A single operator that can affect the resulting value of a variable.
Unary operators
++ increment
– decrement
- negative
! Means variable or constant is negated
Example of a function with a return type String..
func heyName(name: String) -> String { var greeting = "Hello \(name)" return greeting }
Allows you to create a new type that groups several related values.
Enum.
enum Coin {
case Penny, Nickel, Dime, Quarter
}
Penny etc are called “Members”
What is a Switch statement?
A switch statement considers a value and compares it against several possible matching patterns. It then executes an appropriate block of code, based on the first successful match. switch somevalue { case value 1: respond to value 1 case value 2, value 3: respond to value 2 or 3 default: otherwise do this }
Adds an element to an array.
Can also update a car in middle of array.
Var.append( )
Property of an array that counts the number of items in a given array.
Var.count
What is an array?
A sequential list of variables. Always starts at 0, increments by one in order.
Var todo[string] = [“call”,”suck”]
To add a value on end:
todo += [“swallow”]
A single operator that can affect the resulting value of a variable.
Unary operators
++ increment
– decrement
- negative
! Means variable or constant is negated
Example of a function with a return type String..
func heyName(name: String) -> String { var greeting = "Hello \(name)" return greeting }
Allows you to create a new type that groups several related values.
Enum.
enum Coin {
case Penny, Nickel, Dime, Quarter
}
Penny etc are called “Members”
What is a Switch statement?
A switch statement considers a value and compares it against several possible matching patterns. It then executes an appropriate block of code, based on the first successful match. switch somevalue { case value 1: respond to value 1 case value 2, value 3: respond to value 2 or 3 default: otherwise do this }
Adds an element to an array.
Can also update a car in middle of array.
Var.append( )
What is Concatenation? Provide an example.
Adding objects together:
var greeting = “Hello” + language