/* Empty-fit operator 1: empty-fit operator?? Must be an optional type 2: binocular operator, meaning that the front if not empty, then return to the front (arbitrarily unpacked), or return to the back. The following must not be empty. */var Emptyarra:[int]?var emptyarrb:[int]=[4,5]/* Two return meaning, executed is above the */func getnotnoneempty (), [Int] {if Emptya RrA?. Count?? 1 > 0{return Emptyarra?? EMPTYARRB} return (Emptyarra! = nil)? emptyarra! : Emptyarrb}print (Getnotnoneempty ())/*=== operator, determines whether two instances are the same instance, can only be used for reference types ~*/class Testoperator {var p:int = 0}let T1 = TestO Perator () Let t2 = T1t2.p=9print ("issame:\ (T1===T2) t1.p=\ (T1.P)")/*$ operator, if not, you have to have a formal parameter, such as emptyarrc~ need to note that if you use the $ access, To give a type, unexplained ~*/let EMPTYARRC = emptyarrb.map {(avalue:int), Int in if Avalue > 3 {return avalue + 4 } return Avalue}print (EMPTYARRC) let emptyarrd:[int] = Emptyarrb.map ({if $ > 3 {return $4} r Eturn $}) print (EMPTYARRD) func emptymap (avalue:int), Int {if avalue > 3 {return avalue + 4} RE Turn Avalue}let Emptyarre = Emptyarrb.map (emptymap) print (Emptyarre)
[Swift Learning seven] several operator exercises