Amazing explanation on how to convert legacy java projects to kotlin. I have in past converted small spring project into kotlin using intelliJ and have followed most of steps similar to your approach, But now I have a better understanding of sequence of steps I should have taken. Thank you for all the link to commits too. I wouldn't have understand few stuffs if you hadn't provided that.
I also thank you for link to Stevey's article. I enjoyed reading it too.
Can you explain a bit more about List.fold(), I read kotlin documentation on it and then tried going through that commit but have no clue what happened there. There were so many checks in before code, how are they handled by fold(), Its trippy.
One of the most salient features of our Tech Hiring culture is that there is so much bullshit. Everyone knows this. Each of us contributes his share. But we tend to take the situation for granted.
Thanks a lot for your comment, this article was fun to write but I had no idea if it would be useful.
Fold() can be used for example to reimplement the sum of elements in a list. You give it an initial value (0), and a function that you apply to an accumulator (your sum so far) and each next element
Before we treated what happened if you had 0, 1 or more than 1 element. Instead we could handle the case with 0 elements or more than 0. Next step was to use fold().
Ok, So isEmpty check is replaced by having an initial value as parameter of fold. case for 1 or more is handled by lambda. I think I understand it now. So those check-steps are not needed anymore.
acc will be initialized as empty setOf string because that is what is passed inside fold(), c will be current iterated value. and then you call combineSolutions with acc and mapPin of c.
One of the most salient features of our Tech Hiring culture is that there is so much bullshit. Everyone knows this. Each of us contributes his share. But we tend to take the situation for granted.
Amazing explanation on how to convert legacy java projects to kotlin. I have in past converted small spring project into kotlin using intelliJ and have followed most of steps similar to your approach, But now I have a better understanding of sequence of steps I should have taken. Thank you for all the link to commits too. I wouldn't have understand few stuffs if you hadn't provided that.
I also thank you for link to Stevey's article. I enjoyed reading it too.
Can you explain a bit more about List.fold(), I read kotlin documentation on it and then tried going through that commit but have no clue what happened there. There were so many checks in before code, how are they handled by
fold()
, Its trippy.Thanks a lot for your comment, this article was fun to write but I had no idea if it would be useful.
Fold() can be used for example to reimplement the sum of elements in a list. You give it an initial value (0), and a function that you apply to an accumulator (your sum so far) and each next element
See pl.kotl.in/5WMtht8FA
Before we treated what happened if you had 0, 1 or more than 1 element. Instead we could handle the case with 0 elements or more than 0. Next step was to use fold().
Ok, So
isEmpty
check is replaced by having an initial value as parameter of fold. case for 1 or more is handled by lambda. I think I understand it now. So those check-steps are not needed anymore.acc
will be initialized as empty setOf string because that is what is passed inside fold(),c
will be current iterated value. and then you callcombineSolutions
with acc and mapPin of c.Man lambdas are trippy.
Exactly 👏🏻