What is the difference between closure and function in swift?



What is the difference between closure and function in swift?..

Answer / Manoj Kumar Chaubey

"A closure in Swift is a block of reusable code that can be passed around and used in your app. It is syntactically similar to a function but does not have a name. Functions, on the other hand, are named blocks of reusable code that perform an action or return a value. Closures can capture and store references to any constants and variables from the context in which they are defined."

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Apple iOS Swift Interview Questions

Consider the following code: let op1: Int = 1 let op2: UInt = 2 let op3: Double = 3.34 var result = op1 + op2 + op3 Where is the error and why? How can it be fixed?

1 Answers  


What is the difference between swift and ‘objective-c’ language?

1 Answers  


In Swift How to connect UI under Swift Environment ?

1 Answers  


How to add an element into an array?

1 Answers  


Why is inheritance not desirable in swift?

1 Answers  


What is the swift main advantage?

1 Answers  


Does swift have a runtime?

1 Answers  


What are the different collection types available in swift?

1 Answers  


What are floating point numbers? How many types of floating number are there?

1 Answers  


What is “defer”?

1 Answers  


Is swift compiled or interpreted?

1 Answers  


What is swift property?

1 Answers  


Categories