02 函数

作者: zzzzzzzgk | 来源:发表于2016-09-09 18:57 被阅读0次

对元组进行解析

func thrid<A,B,C>(x:(A,B,C))->C{
    switch x {
    case (_,_,let x3):
        return x3
    }
}
thrid((1,1.0,"3"))
//输出 “3”
third (a, b, c) = c

third (1,1.0,"3")
--输出 “3”

not函数

enum Bool1{
    case True1
    case False1
}

func not(x:Bool1) -> Bool1 {
    switch x {
    case .True1:
        return .False1
    case .False1:
        return .True1
    }
}
data Bool1 = True1|False1

not1 :: Bool1 -> Bool1
not1 True1 = False1
not1 False1 = True1

相关文章

网友评论

      本文标题:02 函数

      本文链接:https://www.haomeiwen.com/subject/grgeettx.html