풍's토리

반응형

import UIKit

 

var str = "Hello, playground"

 

func addNum() {

    let a = 10

    let b = 20

    print(a + b)

}

addNum()

 

//argument

func addNum2(arg a:Int) {

    let b = a

    print(b)

}

addNum2(arg:5)

 

//arguments

func addNum3(arg1 a:Int, arg2 b:Int) {

    let c = a + b

    print(c)

}

addNum3(arg1:1, arg2:2)

//addNum3(arg2:1, arg1:2) => error

 

//return

func addNum4(arg1 a:Int, arg2 b:Int) -> Int {

    let c = a + b

    return c

}

var ret = addNum4(arg1:100, arg2:120)

print(ret)

 

//using-and arguments #1

func addNum5(using a:Int, and b:Int) -> Int {

    let c = a + b

    return c

}

print(addNum5(using:7, and:8))

 

//using-and arguments #2

func addNum6(using:Int, and:Int) -> Int {

    let a = using + and

    return a

}

print(addNum6(using:3, and:7))

 

//simple argument

func addNum7(_ a:Int, _ b:Int) {

    let c = a + b

    print(c)

}

addNum7(2, 3)

'메뉴 일곱' 카테고리의 다른 글

[ios] swift 체험하기 #5 클래스  (0) 2019.04.10
[ios] swift 체험하기 #3 반복문  (0) 2019.04.08
[ios] swift 체험하기 #2 제어문  (0) 2019.04.05