diff --git a/README.md b/README.md
index b388793..35218e8 100644
--- a/README.md
+++ b/README.md
@@ -6,11 +6,11 @@
## Why?
You can do this:
```swift
-let titleLabel = UILabel().ch
+let titleLabel = UILabel().set
.text("Welcome")
.font(.systemFont(ofSize: 20))
.textAlignment(.center)
- .ch
+ .get
```
Instead of this:
```swift
@@ -49,7 +49,7 @@ You will be able to do:
```swift
let myClass = MyClass()
-myClass.ch
+myClass.set
.text("It works")
.int(99)
.myEnum(.value2)
@@ -59,11 +59,11 @@ print(myClass.int) // 99
print(myClass.myEnum) // .value2
/// immediate usage
-let myClass = MyClass().ch
+let myClass = MyClass().set
.text("It works")
.int(99)
.myEnum(.value2)
- .ch // gains the instance back
+ .get // gains the instance back
```
## How it works?
diff --git a/Sources/ChainSwift/ChainSwift.swift b/Sources/ChainSwift/ChainSwift.swift
index 9977595..3b36173 100644
--- a/Sources/ChainSwift/ChainSwift.swift
+++ b/Sources/ChainSwift/ChainSwift.swift
@@ -7,14 +7,14 @@
@dynamicMemberLookup
public struct Chain {
- public var ch: Base
+ public var get: Base
init(_ base: Base) {
- self.ch = base
+ self.get = base
}
public subscript(dynamicMember keyPath: WritableKeyPath) -> Callable {
- Callable(ch, keyPath: keyPath)
+ Callable(get, keyPath: keyPath)
}
}
@@ -37,16 +37,12 @@ public class Callable {
public protocol Chainable {
associatedtype ChainableBase
- static var ch: Chain.Type { get }
- var ch: Chain { get }
+ var set: Chain { get }
}
public extension Chainable {
- static var ch: Chain.Type {
- Chain.self
- }
-
- var ch: Chain {
+ var set: Chain {
Chain(self)
}
}
+
diff --git a/Tests/ChainSwiftTests/ChainSwiftTests.swift b/Tests/ChainSwiftTests/ChainSwiftTests.swift
index 3174221..f18174a 100644
--- a/Tests/ChainSwiftTests/ChainSwiftTests.swift
+++ b/Tests/ChainSwiftTests/ChainSwiftTests.swift
@@ -10,6 +10,8 @@ class MyClass {
var text = ""
var int = 0
var myEnum: MyEnum = .value1
+
+ static var next = 2
}
struct MyStruct {
@@ -34,7 +36,7 @@ final class ChainSwiftTests: XCTestCase {
XCTAssertEqual(myClass.int, 0)
XCTAssertEqual(myClass.myEnum, .value1)
- myClass.ch
+ myClass.set
.text("It works")
.int(99)
.myEnum(.value2)
@@ -45,11 +47,11 @@ final class ChainSwiftTests: XCTestCase {
}
func testTakingChValueWorks() {
- let myClass = MyClass().ch
+ let myClass = MyClass().set
.text("It works")
.int(99)
.myEnum(.value2)
- .ch
+ .get
XCTAssertEqual(myClass.text, "It works")
XCTAssertEqual(myClass.int, 99)
@@ -63,11 +65,11 @@ final class ChainSwiftTests: XCTestCase {
XCTAssertEqual(myStruct.int, 0)
XCTAssertEqual(myStruct.myEnum, .value1)
- let updatedMyStruct = myStruct.ch
+ let updatedMyStruct = myStruct.set
.text("It works")
.int(99)
.myEnum(.value2)
- .ch
+ .get
XCTAssertEqual(myStruct.text, "")
XCTAssertEqual(myStruct.int, 0)