티스토리 뷰

ios

func (func)

boywin1992 2022. 5. 23. 20:45
728x90

let a = 100

let b = 200

func plus (num001 : Int, num002 : Int) -> (Int) {

    return (num001 + num002)

}

 

func minus (_ num001 : Int, _ num002 : Int) -> (Int) {

    return (num001 - num002)

}

 

func multiply (_ num001 : Int, _ num002 : Int) -> (Int) {

    return (num001 * num002)

}

 

var inputButtonType = "+"

 

if inputButtonType == "+" {

    print("result", plus(num001: a, num002: b))

} else if inputButtonType == "-" {

    print("result", minus(a, b))

} else if inputButtonType == "*" {

    print("result", multiply(a, b))

}

 

func displayCalc(result: ((Int, Int) -> Int)) {

    print("result", result(a, b))

}

 

if inputButtonType == "+" {

    displayCalc(result: plus)

}

728x90

'ios' 카테고리의 다른 글

enum : Int  (0) 2022.05.24
main interface (start view)  (0) 2022.05.24
function  (0) 2022.05.23
closure  (0) 2022.05.23
check positive number || upper case || check lower case  (0) 2022.05.22
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
글 보관함