+ 1

Incomptable Type

I don't know what the error is , and where is Boolean exist in this code . Anybody can solve this error https://code.sololearn.com/c9nT93RoSHJY/?ref=app

17th Apr 2022, 5:45 AM
Akash Agrawal
Akash Agrawal - avatar
3 ответов
+ 2
I think you are using the when in a wrong way, if i check with the sololearn lessons, it should look more like this: val result = when { size==1 -> msg+list.first() size>=2 -> msg+list.joinToString("and") else -> msg+list.subList(0,size-2).joinToString(",")+"and "+list.last() } return result and the second condition should be size>=2
17th Apr 2022, 6:21 AM
Paul
Paul - avatar
+ 1
The when(size) should be when.
17th Apr 2022, 6:29 AM
Paul
Paul - avatar
17th Apr 2022, 6:31 AM
Paul
Paul - avatar