Josh Skeen

SAM Type Conversion in Kotlin

Josh Skeen | Sep 17, 2018

Just like Java 8, Kotlin supports SAM conversions. This means that Kotlin function literals can be automatically converted into implementations of Java interfaces with a single non-default method, as long as the parameter types of the interface method match the parameter types of the Kotlin function.

SAM type conversions allow interfaces which require an implementation of a single method to accept either an anonymous class or a lambda.

In this screencast, we will do a recap on SAM Types, see how they work in Kotlin to support Java interoperability, and we'll also see some of the "gotchas" involved with the feature.

Basic knowledge or experience building Android applications is recommended.

For the More Curious...

SAM Conversions
BNR Guide to Kotlin
Android & Kotlin Courses

Subscribers Only

Transcripts are for subscribers. Create an account today to access our collection of screencasts, skill packs, and more.

Subscribers Only

Project files are only available for subscribers. Create an account today to access our collection of screencasts, skill packs, and more.

Need Help?

If you get stuck, try starting a discussion with Big Nerd Ranch experts in the community tab.

Skill Pack

This screencast is part of a skill pack called Getting Started with Kotlin.

Related Screencasts

Explore other screencasts related to this topic.