122: Learning Kotlin – typealias

In this episode of learning kotlin, we look at the typealias keyword. The typealias keyword allows you to provide alternate names for existing types and and function types. Learn how, why and when you can use it in this episode

Direct Download

Show Notes

Sponsors

  • Microsoft AppCenter – Sign up now on appcenter.ms and spend less time managing your app lifecycle and more time coding.

Contact

121: Functional Programming with Kotlin Arrow team – II

In this episode of Fragmented, we wrap up another 2 part series. We dive into the details of the Arrow library with this one. Arrow is a library in Kotlin that helps bring many of the functional paradigms of programming to your daily development. We talk to the team about how it all started, the history of the library, why we even need arrow, how Arrow is structured, some of the pitfalls, and in the end some resources on getting us started with Arrow.

Direct download

Show Notes

Arrow library

Misc

Get help on Arrrow

Sponsors

  • Microsoft AppCenter – Sign up now on appcenter.ms and spend less time managing your app lifecycle and more time coding.

Contact

120: Functional Programming with Kotlin Arrow team

In this episode of Fragmented, we kick off another 2 part series. This time it’s with the Kotlin Arrow team! In the first part, we talk to Jorge, Raul and Paco about Functional programming in general, some core FP concepts, do we already use functional programming today, what are pure functions, do I need to know complicated math to do FP, Immutability, Referential transparency and so much more. These are all pretty daunting words, but the Arrow team break it down and make it really simple for us to understand.

Listen on to the show.

Download directly

Show Notes

Kotlin Arrow team

Misc

Sponsors

  • Microsoft AppCenter – Sign up now on appcenter.ms and spend less time managing your app lifecycle and more time coding.

Contact

109: Learning Kotlin – Sequences the new Iterables

In this episode of Fragmented, we go back to learning some Kotlin and look at the Iterable like data structure introduced called “Sequences”. What is a sequence? How is it different from Iterable? When should I use it?

Download directly

Show Notes

Eager/Lazy

Eager evaluation:

val lst = listOf(1, 2)
val lstMapped: List<Int> = lst.map { print("$it "); it * it }
print("before sum ")
val sum = lstMapped.sum()

// prints "1 2 before sum"

Lazy evaluation:

val seq = sequenceOf(1, 2)
val seqMapped: Sequence<Int> = seq.map { print("$it "); it * it }
print("before sum ")
val sum = seqMapped.sum()

// prints "before sum 1 2"

Source stackoverflow.com answer

Intermediate and terminal operations

Notice that at each chain operation, a new temporary list is created:

data class Person(val name: String, val age: Int)

fun main(args: Array<String>) {
    val people = 
        listOf(Person("Chris Martin", 31), 
               Person("Will Champion", 32),
               Person("Jonny Buckland", 33),
               Person("Guy Berryman", 34),
               Person("Mhris Cartin", 30))

    println(people
            .filter { it.age > 30 } // new temp. list
            .map {                  
                it.name.split(" ").map {it[0]}.joinToString("")
            }  // new temp. list
            .map { it.toUpperCase() }) // new temp. list
}

Using a sequence:

println(people
        .asSequence()  // convert to sequence
        .filter { it.age > 30 } // lazy eval (intermediate op)
        .map {                  
            it.name.split(" ").map {it[0]}.joinToString("")
        }  // lazy eval (intermediate op)
        .map { it.toUpperCase() }  // lazy eval (intermediate op)
        .toList() // terminal operation
       )

Without a terminal operation, Sequences won’t print anything:

val seq = sequenceOf(1, 2, 3)
println(seq) // prints address
println(seq.toList()) // [1, 2, 3]

You can’t pick an index from a sequence:

println(seq[0]) // throws ERROR "No get method providing array access"
println(seq.toList()[0]) // 1

Sponsors

Contact

105: Jake Wharton on the Android Kotlin Guides

In this episode, we talk to Jake Wharton of Google on a recent Kotlin coding style guide that they released: the Android Kotlin Guides. In this episode, we pick his brains and ask him how he structured the guide, how he partitioned it to fit some of the idiosyncrasies of Kotlin, what some of the challenges were, when coming up with the guide and much more.

Jake’s one of the best out there and it’s always such a pleasure to have him on the show.

Download directly

Show Notes

The style guides

Building the style guide

Android Kotlin Guides

Mockito when problems:

Misc

Contributing

Sponsors

Contact