본문 바로가기

Programming/Swift

(68)
Functions with Parameters func sayHelloToStudent(student: String) { print("Hello, \(student)!") } sayHelloToStudent(student: "Sunny") 결과값 Hello, Sunny!
Introduction to Functions var name = "Ayush" var age = 19 var onGuestList = true var knowsTheOwner = false if onGuestList && age >= 21 { print("\(name), come party with us!") } else if knowsTheOwner { print("\(name), we'll have to take you to the owner.") } else { print("Sorry, \(name), maybe you can go play Bingo with me.") }
Apple's Basic Operators documentation for Swift docs.swift.org/swift-book/LanguageGuide/BasicOperators.html Basic Operators — The Swift Programming Language (Swift 5.3) Basic Operators An operator is a special symbol or phrase that you use to check, change, or combine values. For example, the addition operator (+) adds two numbers, as in let i = 1 + 2, and the logical AND operator (&&) combines two Boolean values, as in i docs.swift.org
Expressions docs.swift.org/swift-book/ReferenceManual/Expressions.html Expressions — The Swift Programming Language (Swift 5.3) Expressions In Swift, there are four kinds of expressions: prefix expressions, binary expressions, primary expressions, and postfix expressions. Evaluating an expression returns a value, causes a side effect, or both. Prefix and binary expressions let you docs.swift.org
Order of Operations www.mathsisfun.com/operation-order-pemdas.html
Introduction to Operators and Expressions Operators are special symbols or phrases that can be used to check, change, or combine values. Expressions are statements that can be reduced to a single value. In programming lingo, you’d say expressions are statements that return a single value.
String Interpolation The syntax (문법) for string interpolation is: backslash, open parenthesis, variable name, closed parenthesis. interpolation = addition \ backslash open parenthesis The open parenthesis, which looks like (, is used to begin parenthetical text. The close parenthesis, ), denotes the end of parenthetical text. Example) var name = "Sunny" var customizedGreeting = "Good Morning, \n\(name)!" print (cust..
Escape Characters in Swift Special Characters in String Literals The escaped special characters \0 (null character), \\ (backslash), \t (horizontal tab), \n (line feed), \r (carriage return), \" (double quotation mark) and \' (single quotation mark) docs.swift.org/swift-book/LanguageGuide/StringsAndCharacters.html#:~:text=String%20literals%20can%20include%20the,and%20%5C'%20(single%20quotation%20mark) let a = "\"Hello\nWo..