165: Learning Kotlin: Lambda Expressions Part 1


Download

In this episode, Donn talks about Kotlin Lambda Expressions. He explains the syntax and how to build a couple of simple lambda expressions with and without type inference and declaration. We wrap up with a small example of passing a small lambda with multiple values to a function. See the show notes below for more info. This is part 1 of a multi-part series on Lambda Expressions in Kotlin.

The basic syntax of a lambda expression: kotlin
val myLambda : Type = { argumentList -> codeBody }

The codeBody is the only section that is not optional.

Double lambda expression (doubles an integer) with type inference kotlin
val double = { number: Int -> number * 2 }
val result = double(4)
// result = 8 now

Double string multi-line lambda with type inference. kotlin
val doubleString = { number: Int ->
// codebody
val doubleResult = number * 2
doubleResult.toString()
// Kotlin knows this will return a string
}

Type declaration in a lambda kotlin
val myLambda: (String, Int) -> String = { str, int ->
"$str - ${int.toString()}" // "Donn - 32"
}
val result = myLambda("Donn", 32)
// result = "Donn - 32"

Preview of next week … passing a lambda to a function `\kotlin fun doWork(name: String, favoriteNumber: Int, someLambda: (String, Int) -> String) { // Do some processing, this is a contrived example val repeatedString = “$name$name” val result = someLambda(repeatedString, favoriteNumber) println(result) }

// Usage doWork(“Donn”, 32) { str, int -> val someNewValue = “$str is my parameter and so is $int” someNewValue.length.toString() // this is returned }

// ’37’ is printed via println

// Or use it like this, the lambda code body is what can change, this is where the power is at doWork(“Donn”, 32) { name, count -> var result = “” for(i in 1..count) { result += “$name” } result // this is returned }

// loops over and concatinates “Donn” until the favorite number (aka count) is met. // Output looks like: “DonnDonnDonnDonnDonnDonn…” and so on…

`\

164: Learning Kotlin: Sealed Classes


Download

In this episode, you’ll learn all about Kotlin Sealed classes. Donn walks you through what they are, how to create them, how to use data classes, objects and regular classes to create a restricted type hierarchy.

Sponsors 🙏

Contact

163: Parallelize Your Espresso Tests with Flank w/ Matt Runo

In this episode, Donn talks to Matt Runo about the Flank project. Using Flank you can run your Espresso test suite in parallel on Firebase Test Lab (FTL). This allows you to lower your feedback loop time and increase developer productivity and throughput. You’ll learn all about Flank, how it works and how to get started in this episode.

Download

Sponsors 🙏

Contact

162: Catching up on Google IO 2019


Download

Shownotes

Contact

Sponsors 🙏

  • Instabug – Instabug is an SDK that completely takes care of your beta testing and user feedback process so you can debug, fix, and improve your app quality faster. Go to instabug.com/fragmented, signup, install the SDK, and you will get their brand new t-shirt and a 14-day free trial.

161: Machine Learning on Android with ML Kit and TensorFlow with Dan Jarvis


Download

In this show, Donn talks with Dan Jarvis about Machine Learning on Android with ML Kit and Tensor flow.

They dive deep into what ML (Machine Learning) is, what you need to know as a developer and how to apply those things to build ML applications on Android.

They tal about what you can do on Android in regards to ML, model training and running the models on the device. You may be wondering if you should include the model in your app or if it should live on a server, that’s discused as well and the reasons for it.

They wrap up the show with some examples of what you could build and some great resources to get you started.

Enjoy

Shownotes

Sponsors 🙏

Contact