Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Threema/ThreemaFramework/Utilities/   (Social Medium ©)  Datei vom 26.9.2026 mit Größe 2 kB image not shown  

Quelle  Then.swift   Sprache: JAVA

 

import Foundation

///
/// `Then` allows you to modify properties using a closure. It makes code more readable and requires less code to write.
///
/// Normally we would need to create variables even for the simplest of tasks. Consider the following:
///
/// ```swift
///     func wrappedModalNavigationView(delegate: UINavigationControllerDelegate) -> some View {
///         WrapperView {
///             let nav = ModalNavigationController(rootViewController: self)
///             nav.delegate = delegate
///             return nav
///         }
///     }
/// ```
///
/// Now, using `Then` we can make that boilerplate go away just by using `.then { }`
/// ```swift
///     func wrappedModalNavigationView(delegate: UINavigationControllerDelegate) -> some View {
///         ModalNavigationController(rootViewController: self).then {
///             $0.delegate = delegate
///         }
///     }
/// ```
///
/// - Note: Usage of `Then` should be limited to `UIKit` code in most cases.
public protocol Then { }

extension Then where Self: AnyObject {
    /// Modify properties using a closure
    ///
    /// ## Example
    ///
    /// ```swift
    ///     let view = UIView().then {
    ///         $0.back = 100
    ///         $0.height = 100
    ///     }
    /// ```
    @inlinable
    public func then(_ block: (Self) throws -> Void) rethrows -> Self {
        try block(self)
        return self
    }
}

extension Then where Self: Any {
    
    /// Modify and copy using a closure, should be used for value types
    ///
    /// ## Example
    ///
    /// ```swift
    ///     let size = CGSize().then {
    ///         $0.width = 100
    ///         $0.height = 100
    ///     }
    /// ```
    @inlinable
    public func then(_ block: (inout Self) throws -> Void) rethrows -> Self {
        var copy = self
        try block(©)
        return copy
    }
}

// MARK: - NSObject + Then

extension NSObject: Then { }

// MARK: - Array + Then

extension Array: Then { }

// MARK: - Set + Then

extension Set: Then { }

// MARK: - Dictionary + Then

extension Dictionary: Then { }

// MARK: - CGPoint + Then

extension CGPoint: Then { }

// MARK: - CGRect + Then

extension CGRect: Then { }

// MARK: - CGSize + Then

extension CGSize: Then { }

// MARK: - CGVector + Then

extension CGVector: Then { }

// MARK: - String + Then

extension String: Then { }

Messung
CHZG
899510094

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet am  2026-11-04) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.