function - Swift 3 custom parameter types -
i'm sorry if has been asked before, can't find answer. create custom parameter types function.
typedef?/define type
direction { lefttoright, righttoleft };
function:
class func animatein (dir:direction) { if dir = lefttoright { // animate left right } else { // animate right left } }
call:
animatein (dir:lefttoright)
enum
seems perfect candidate use. if plan have more cases in enum
, switch statement seems more feasible inside function.
enum direction { case lefttoright, righttoleft } class func animatein(dir: direction){ switch dir{ case .lefttoright: //do case .righttoleft: //do } }
Comments
Post a Comment