Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

closures as parameters explained

let driving = {
    print("hi there.")
}

func travel(action: () -> Void) {
     action()
    
}

travel(action: driving)

*Driving function enters action: () and then is called. 
This prints "hi there"
 
PREVIOUS NEXT
Tagged: #closures #parameters #explained
ADD COMMENT
Topic
Name
7+6 =