Fragmented - Android Developer Podcast
168: Learning Kotlin: Lambda Expressions Part 2
- Autor: Vários
- Narrador: Vários
- Editora: Podcast
- Duração: 0:21:37
- Mais informações
Informações:
Sinopse
In this episode, Donn continues his talks about Kotlin Lambda Expressions. He explains how you can use lambda expressions as function parameters and as return types for functions. This is a very dense episode - if you get lost look at the code snippets below or view on them on fragmentedpodcast.com class LogReader { fun processFile(file: File, processLine: (String) -> Unit = {}) { file.forEachLine { println("Number of Chars: ${it.length}") processLine(it) println("Line Done Processing") } } fun processFileWithHandlers(file: File, logHandler: LogHandler) { file.forEachLine { println("Start of Processing") logHandler.handleLine().forEach { handler -> handler(it) } println("Line Done Processing") } } } interface LogHandler { fun handleLine(): List<(String) -> Unit> } val reader = LogReader() val textFile = File("/Users/donnfel