Skip to content

Commit

Permalink
Wrong implementation of 'containsSingleProduct'
Browse files Browse the repository at this point in the history
  • Loading branch information
serras committed Dec 15, 2021
1 parent 86e3bf4 commit 6ec793a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/kotlin/io/arrow/example/MetaExamples.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ package io.arrow.example
import arrow.optics.Every

// WRONG
// fun Order.containsSingleProductWrong() =
// entries.all { entry -> entry.id == entries[0].id }
fun Order.containsSingleProductWrong() =
entries.all { entry -> entry.id == entries[0].id }

// RIGHT
fun Order.containsSingleProductRight() =
if (entries.isEmpty()) false
else entries.all { entry -> entry.id == entries[0].id }
// fun Order.containsSingleProductRight() =
// if (entries.isEmpty()) false
// else entries.all { entry -> entry.id == entries[0].id }

fun Order.addOneFreeNoOptics(): Order =
Order(entries.map { it.copy(amount = it.amount + 1) })
Expand Down

0 comments on commit 6ec793a

Please sign in to comment.