Skip to content

Latest commit

History

History
executable file
103 lines (76 loc) 路 2.54 KB

README.md

File metadata and controls

executable file
103 lines (76 loc) 路 2.54 KB


Version Author Build Passing Swift
Platforms MIT
Cocoapods Carthage SPM

Introduction

What's this?

With DeftEquatable, you NEVER implement Equatable manually again.

Installation

CocoaPods

pod 'DeftEquatable'

Contribution

You are welcome to fork and submit pull requests.

License

DeftEquatable is open-sourced software, licensed under the MIT license.

Usage

import DeftEquatable

class MyClass: DeftEquatable {
    let myString: String
    let myInt: Int

    init(myString: String, myInt: Int) {
        self.myString = myString
        self.myInt = myInt
    }
}

class MyClassWithAnotherClass: DeftEquatable {
    let myClass: MyClass

    init(myClass: MyClass) {
        self.myClass = myClass
    }
}

enum GenericEnum: DeftEquatableEnum {
    case one
    case two
}

class MyClassWithGenericEnum: DeftEquatable {
    let myEnum: GenericEnum

    init(myEnum: GenericEnum) {
        self.myEnum = myEnum
    }
}

class MyClassWithArray<T>: DeftEquatable {
    let myArray: [T]

    init(myArray: [T]) {
        self.myArray = myArray
    }
}
let one = MyClass.init(myString: "somethings", myInt: 1)
let two = MyClass.init(myString: "somethings", myInt: 2)

let three = MyClassWithAnotherClass.init(myClass: two)
let four = MyClassWithAnotherClass.init(myClass: two)

let five = MyClassWithGenericEnum.init(myEnum: .one)
let six = MyClassWithGenericEnum.init(myEnum: .two)

let seven = MyClassWithArray<Int>.init(myArray: [1,2,3])
let eight = MyClassWithArray<Int>.init(myArray: [1,2,3])

print(one == two) // false
print(three == four) // true
print(five == six) // false
print(seven == eight) // true