Kotlin / kotlin-koans

Kotlin workshop
MIT License
2.6k stars 1.41k forks source link

Bug in Collections/Compound tasks? #167

Open ttoomm318 opened 6 years ago

ttoomm318 commented 6 years ago

There seems to be a bug with the test(s) for fun Shop.getNumberOfTimesProductWasOrdered(product: Product): Int

I've tried the the following two solutions:

Provided solution:

fun Shop.getNumberOfTimesProductWasOrdered(product: Product): Int {
    return customers.flatMap { it.getOrderedProductsList() }.count { it == product }
}

fun Customer.getOrderedProductsList(): List<Product> {
    return orders.flatMap { it.products }
}

My original solution:

fun Shop.getNumberOfTimesProductWasOrdered(product: Product): Int =
    customers.flatMap { it.orders }.flatMap { it.products }.count { it == product }

at the following two sites:

and I get

Assigning single elements to varargs in named form is forbidden

Just to add, I tried the same solution in the Playground at https://play.kotlinlang.org/ (using the same code from Shop.kt and simplified code from TestShop.kt) and it runs fine, giving the correct result.

I've attached the file with code copied from Playground. Kotlin Playground.kt.zip

antohaby commented 6 years ago

Got yesterday same issue. Because of that cant make 100% progress :(

It seems that it was fixed before https://github.com/Kotlin/kotlin-koans/commit/888c9a17a9130f69aa96a3f85014305591c22127 when it was just a deprecation.

EhsanKia commented 6 years ago

I just hit this now. The easy temporary solution is to change the runtime to something other than 1.3 in the bottom right corner.

ivannarino commented 5 years ago

The bug is still there

davidgiessing commented 5 years ago

Just hit the bug. It is just the testcase that is (now) wrong since it tries to assign a single value in named form to a collection. However @EhsanKia s temporary workaround does indeed work.

h8 commented 5 years ago

The bug is still not fixed, and looks like there is no way to change the Kotlin version in Koans.

regulus33 commented 5 years ago

Still there for me too :( its a shame I won't be able to get satisfaction of seeing 100% in the progress bar now 😢

mgwizdal commented 5 years ago

Its still not working :(

AlexanderPrendota commented 5 years ago

@mgwizdal please hard refresh the page

mgwizdal commented 5 years ago

@AlexanderPrendota Tried on different browsers and refreshsed hard - still the same issue

AlexanderPrendota commented 5 years ago
Screen Shot 2019-05-29 at 11 05 52 AM

Please try one in private mode. Maybe it helps. Thanks