ikesyo / swift-with-previous

A Swift property wrapper which stores the previous value

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

swift-with-previous

A Swift property wrapper which stores the previous value. The previous value can be get by the projected value $propertyName.

import XCTest
import WithPrevious

final class WithPreviousTests: XCTestCase {
    @WithPrevious var value = 0

    func testWithPreviousWrapper() {
        XCTAssertEqual(value, 0)
        XCTAssertNil($value)

        value = 10

        XCTAssertEqual(value, 10)
        XCTAssertEqual($value, 0)
    }
}

License

MIT license. See LICENSE for details.

About

A Swift property wrapper which stores the previous value

License:MIT License


Languages

Language:Swift 100.0%