Stylianos Gakis
09/05/2021, 8:24 AMmap
filter
associate
and whatnot, but I wanted to debug it. In Java streams we can use the “trace current stream chain” while debugging, but it seems to be greyed off in Kotlin.
If I use the asSequence
I get this functionality, but is this the only way? Sometimes a sequence doesn’t make sense to use, and using it just to enable this debugging functionality feels wrong, is this my only option?edrd
09/05/2021, 11:49 AMStylianos Gakis
09/05/2021, 11:54 AMJacob
09/05/2021, 2:35 PMStylianos Gakis
09/05/2021, 3:39 PMJacob
09/05/2021, 6:39 PMStylianos Gakis
09/05/2021, 6:58 PMdata class Ticket(val movieName: String, val price: Int, val currencyType: String)
fun whateverList(): List<Ticket> {
return List(1000) {
Ticket("Name$it", (10..39).random(), listOf("EUR", "USD", "SEK").random())
}
}
fun main() {
val itemsList: List<Ticket> = whateverList()
itemsList
.map { it.copy(price = it.price * 2) }
.filter { it.price < 45 }
.associateBy { it.currencyType }
}
So then when I am debugging, and I am for example right after the filter
line, how do I know what kind of data I am working with at that point? (First picture attached)
Now if I attach asSequence first, I am getting this nice window that even visualises it for me (Second picture attached)
And what I am basically asking here, is if I do not convert it to a sequence, is there any way where I can see at this stack frame where I am directly after calling the filter
function how my current list under manipulation looks like. How would “going back one stack frame” help here, can I attach a watch to something while debugging that will show me this? Watching itemsList is obviously not enough because it’s immutable, I am not changing that, I am only getting a new one back at the end of it after the chain of actions is over.Jacob
09/05/2021, 7:31 PMStylianos Gakis
09/05/2021, 7:32 PMJacob
09/05/2021, 8:36 PMStylianos Gakis
09/27/2021, 5:17 AMJacob
09/27/2021, 5:35 AMit
Stylianos Gakis
09/27/2021, 8:25 AM