Kotlin 2025

From bibbleWiki
Revision as of 03:22, 10 March 2025 by Iwiseman (talk | contribs) (Created page with "=Introduction= It has been a while since I last looked at Kotlin. I think I am still and rust fan but always loved Kotlin on the phone. It is probably 4 years and one stroke since I looked at this and my little grey cells need a refresh =Compose= I have covered this a bit in Android Compose Example Surely a major improvement =MVI= I have used MvvM in the past but MVI now looks to be a better choice for me at the moment. You would have to have done a lot of projects t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Introduction

It has been a while since I last looked at Kotlin. I think I am still and rust fan but always loved Kotlin on the phone. It is probably 4 years and one stroke since I looked at this and my little grey cells need a refresh

Compose

I have covered this a bit in Android Compose Example Surely a major improvement

MVI

I have used MvvM in the past but MVI now looks to be a better choice for me at the moment. You would have to have done a lot of projects to know for sure. I only dip my toe it but see Andoroid MVI Example

Now The Notes

Functions

This is just a refresher of the functions from Kotlin. We have

fun timesTwo(it: Int) = it * 2 // Normal fun
val timeThree = { it: Int -> it * 3} // Lambda
val timesFour = (fun (it: Int) = it * 4) // Anonymous function

To pass a function we can use function references. We do this by using the double full colon

fun main() {
    val result3 = perform(::timesTwo)
}

fun perform(operation: (Int) -> Int): Int {
  return operation(5)
}