Update nightly.yml
Sugar for working and using Bool type in Swift.
To streamline writing and reading code so it will resemble the English language.
isTrue
Sugar for checking if Bool has value true. Streamlines conditionals statements by removing explicit checks with ==.
Bool
true
==
if canDrinkBeer.isTrue { ...
isFalse
Sugar for checking if Bool has value false. Streamlines conditionals statements by removing explicit checks with ==.
false
if canDrinkBeer.isFalse { ...
negated
New instance with negated value.
whenTrue
Operator for running a closure when self is true. Use this operator to create pipelines that will trigger actions.
canDrinkBeer .whenTrue { openBeer() } .whenFalse { closeBeer() }
whenFalse
Operator for running a closure when self is false. Use this operator to create pipelines that will trigger actions.
biTransform(yes:no:)
Transforms bool to some type of T. Use this in longer pipelines where sticking normal operators would break the flow:
T
manager .boolProperty .biTransform(yes: "was true", no: "was false") .count // working with String now
and
Sugar for &&. Writing more complex if statements sometimes is messy. With operators you can write them:
&&
if canDrinkBeer .and( isHealthy ) .and( hasMoney ) .or( isFriend ) { ...
or
Sugar for ||. Writing more complex if statements sometimes is messy. With operators you can write them:
||
toInt
Converts to Int. When true returns positive value and for false returns 0. Do not assume any particular integer value for true.
Int
0
init(fromInt:)
Creates Bool instance from Int. When value is 0 returns false and true for all other cases.
value
always
When you need a predicate that is always true or always false you can use a global function like so:
func takesPredicate<A>(_ p: (A) -> Bool) {... } // Before takesPredicate( { _ in true } ) // now takesPredicate( always(true) ) takesPredicate( true.always )
Library for handling predicates as types.
Working on a design and on documentation. You are more than welcome to take a look and play around with it.
This project is part of the 🐇🕳 Rabbit Hole Packages Collection
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
SweetBool
Sugar for working and using Bool type in Swift.
Why?
To streamline writing and reading code so it will resemble the English language.
Operators
isTrue
Sugar for checking if
Bool
has valuetrue
. Streamlines conditionals statements by removing explicit checks with==
.isFalse
Sugar for checking if
Bool
has valuefalse
. Streamlines conditionals statements by removing explicit checks with==
.negated
New instance with negated value.
whenTrue
Operator for running a closure when self is
true
. Use this operator to create pipelines that will trigger actions.whenFalse
Operator for running a closure when self is
false
. Use this operator to create pipelines that will trigger actions.biTransform(yes:no:)
Transforms bool to some type of
T
. Use this in longer pipelines where sticking normal operators would break the flow:and
Sugar for
&&
. Writing more complex if statements sometimes is messy. With operators you can write them:or
Sugar for
||
. Writing more complex if statements sometimes is messy. With operators you can write them:toInt
Converts to
Int
. Whentrue
returns positive value and forfalse
returns0
. Do not assume any particular integer value fortrue
.init(fromInt:)
Creates
Bool
instance fromInt
. Whenvalue
is0
returnsfalse
andtrue
for all other cases.Predicates
always
When you need a predicate that is always
true
or alwaysfalse
you can use a global function like so:SweetPredicate
Library for handling predicates as types.
WiP
Working on a design and on documentation. You are more than welcome to take a look and play around with it.
🐇🕳 Rabbit Hole
This project is part of the 🐇🕳 Rabbit Hole Packages Collection