Top "Closures" questions

A closure is a first-class function that refers to (closes over) variables from the scope in which it was defined.

What's the nearest substitute for a function pointer in Java?

I have a method that's about ten lines of code. I want to create more methods that do exactly the …

java closures function-pointers
Blocks on Swift (animateWithDuration:animations:completion:)

I'm having trouble making the blocks work on Swift. Here's an example that worked (without completion block): UIView.animateWithDuration(0.07) { self.…

ios swift closures
Access to Modified Closure

string [] files = new string[2]; files[0] = "ThinkFarAhead.Example.Settings.Configuration_Local.xml"; files[1] = "ThinkFarAhead.Example.Settings.Configuration_Global.xml"; //Resharper complains …

c# resharper closures
Closure use of non-escaping parameter may allow it to escape

I have a protocol: enum DataFetchResult { case success(data: Data) case failure } protocol DataServiceType { func fetchData(location: String, completion: (DataFetchResult) …

swift xcode swift3 closures
What are 'closures' in C#?

Duplicate Closures in .NET What are closures in C#?

c# closures
Javascript infamous Loop issue?

I've got the following code snippet. function addLinks () { for (var i=0, link; i<5; i++) { link = document.createElement("a"); link.…

javascript closures
Calling an asynchronous function within a for loop in JavaScript

I have the following code: for(var i = 0; i < list.length; i++){ mc_cli.get(list[i], function(err, …

javascript asynchronous for-loop closures
Swift @escaping and Completion Handler

I am trying to understand 'Closure' of Swift more precisely. But @escaping and Completion Handler are too difficult to understand …

swift escaping closures
Swift optional escaping closure parameter

Given: typealias Action = () -> () var action: Action = { } func doStuff(stuff: String, completion: @escaping Action) { print(stuff) action = completion completion() } …

swift function closures optional
How do nested functions work in Python?

def maker(n): def action(x): return x ** n return action f = maker(2) print(f) print(f(3)) print(f(4)) g = …

python function nested closures nested-function