Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member190800
Contributor
We all know didSet() is not called when initializing a property, and we know we can compute an initial value in a closure.

Put them together, and what do you get?
/// The width of the view's top border line.
///
/// Defaults to `2 / UIScreen.main.scale`
public var topBorderWeight: CGFloat = { 2 / UIScreen.main.scale }() {
    didSet {
        setNeedsDisplay()
    }
}