kotlin-koans icon indicating copy to clipboard operation
kotlin-koans copied to clipboard

Bug in Collections/Compound tasks?

Open ttoomm318 opened this issue 7 years ago • 10 comments
trafficstars

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:

  • https://play.kotlinlang.org/koans/Collections/Compound%20tasks/Task.kt
  • https://try.kotlinlang.org/#/Kotlin%20Koans/Collections/Compound%20tasks/Task.kt

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

ttoomm318 avatar Nov 08 '18 13:11 ttoomm318

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.

antohaby avatar Nov 12 '18 15:11 antohaby

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.

EhsanKia avatar Nov 13 '18 06:11 EhsanKia

The bug is still there

ivannarino avatar Jan 22 '19 21:01 ivannarino

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.

davidgiessing avatar Feb 12 '19 09:02 davidgiessing

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

h8 avatar Mar 29 '19 12:03 h8

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

regulus33 avatar Apr 05 '19 12:04 regulus33

Its still not working :(

mgwizdal avatar May 28 '19 20:05 mgwizdal

@mgwizdal please hard refresh the page

AlexanderPrendota avatar May 29 '19 06:05 AlexanderPrendota

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

mgwizdal avatar May 29 '19 07:05 mgwizdal

Screen Shot 2019-05-29 at 11 05 52 AM

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

AlexanderPrendota avatar May 29 '19 08:05 AlexanderPrendota