liveBook · Manning

@escaping

As explained in Classic Computer Science Problems in Swift: Essential techniques for practicing programmers

@escaping is a Swift parameter annotation indicating that a closure may be stored or invoked after the function receiving it returns.

@escaping marks a Swift closure parameter that can be stored or used after the receiving function returns. It is required when an initializer saves the closure for later use. section 7.5

A stored activation function

init(weights: [Double], activationFunction: @escaping (Double) -> Double, derivativeActivationFunction: @escaping (Double) -> Double, learningRate: Double) { self.activationFunction = activationFunction; self.derivativeActivationFunction = derivativeActivationFunction }

How Classic Computer Science Problems in Swift: Essential techniques for practicing programmers covers it

How deep it goes
Defines the lifetime requirement and compiler enforcement, but does not develop closure implementation internals.
Examples
Uses activation and derivative-activation functions stored in a Neuron and passed through Layer and Network initializers.
What it assumes
Assumes familiarity with Swift closures, initializers, stored properties, and methods.
What you can do after
Apply @escaping in Swift initializers that retain closures for later method calls.
How it connects
Connects closures with initializers, stored properties, activation functions, and neural networks.

This explainer was generated by Manning's knowledge graph from the text of Classic Computer Science Problems in Swift: Essential techniques for practicing programmers. The section links point to the parts of the book it draws on.