Skip to content

Commit

Permalink
Merge pull request #193 from xuwei-k/foldLeft
Browse files Browse the repository at this point in the history
use foldLeft instead of /:
  • Loading branch information
farmdawgnation committed May 10, 2018
2 parents 33923f8 + 06cd295 commit d3dc6c1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala/projections.scala
Expand Up @@ -94,7 +94,7 @@ object FutureRightIterable {

private def flatRight[L,R](eithers: Iterable[Either[L,R]]) = {
val start: Either[L,Seq[R]] = Right(Seq.empty)
(start /: eithers) { (a, e) =>
eithers.foldLeft(start) { (a, e) =>
for {
seq <- a.right
cur <- e.right
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/requests.scala
Expand Up @@ -187,7 +187,7 @@ trait HeaderVerbs extends RequestVerbs {
* on the request.
*/
def <:< (hs: Traversable[(String,String)]) = {
(subject /: hs) {
hs.foldLeft(subject) {
case (s, (key, value)) =>
s.addHeader(key, value)
}
Expand All @@ -207,7 +207,7 @@ trait ParamVerbs extends RequestVerbs {
* Sets request method to POST unless it has been explicitly set.
*/
def << (params: Traversable[(String,String)]) = {
(subject.implyMethod("POST") /: params) {
params.foldLeft(subject.implyMethod("POST")) {
case (s, (key, value)) =>
s.addParameter(key, value)
}
Expand Down Expand Up @@ -256,7 +256,7 @@ trait ParamVerbs extends RequestVerbs {
* Adds `params` as query parameters
*/
def <<? (params: Traversable[(String,String)]) = {
(subject /: params) {
params.foldLeft(subject) {
case (s, (key, value)) =>
s.addQueryParameter(key, value)
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/scala/compose.scala
Expand Up @@ -36,7 +36,7 @@ with DispatchCleanup {
}

property("sum in fold") = forAll(numList) { (sample: List[Long]) =>
val res = (Future.successful("0") /: sample) { (p, num) =>
val res = sample.foldLeft(Future.successful("0")) { (p, num) =>
p.flatMap { cur => sum(Seq(cur, num.toString)) }
}
res() ?= sample.sum.toString
Expand Down

0 comments on commit d3dc6c1

Please sign in to comment.