Wrap

4.0.0

`&>` A tiny library that enables us to describe operations in method-chain.
VergeGroup/swift-operator-wrap

What's New

4.0.0

2023-11-30T10:43:01Z

What's Changed

New Contributors

  • @muukii made their first contribution in #2

Full Changelog: 3.0.0...4.0.0

value&>.do { ... }

A tiny library that enables us to describe operations in method-chain.

Usage

let result: String = ""&>.map { Int($0) }&>.do { print($0 as Any) }

let value: String? = ""&>.filter { !$0.isEmpty }

let view: UIView = UIView()&>.do {
  $0.backgroundColor = .white
}

Motivation

Actually, I'm not addicted to getting a custom operator.
However a global function or operator are the only way to add a new feature without customizing our own types.

Another way is using something protocol and extending it like this.
It can not be used in struct without adding that protocol.

In fact, this structure looks very natural, because the all of method chaining in Swift standard libary come from an kind of monad.
Like, Optional, Array and Dictionary.

And this keeps Swift clean code base at the beginning.
You have no methods at you declared a struct!

Description

  • Swift Tools 5.5.0
View More Packages from this Author

Dependencies

  • None
Last updated: Mon Mar 18 2024 01:15:40 GMT-0900 (Hawaii-Aleutian Daylight Time)