Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kotlin: Function Literals with Receiver

Kotlin: Function Literals with Receiver

A brief introduction to Function Literals with Receiver in Kotlin including what they are, how to use them and some examples.

This was a lightning talk from a Chicago Kotlin User Group meetup https://www.meetup.com/Chicago-Kotlin/events/260292217.

Ryan Casler

May 22, 2019
Tweet

Other Decks in Technology

Transcript

  1. Lambda A type of function literal using curly braces EX.

    val sum = { x: Int, y: Int -> x + y }
  2. What Are They • A function • Can be passed

    into other functions • Can be a Lambda • Has access to the receivers members
  3. Batch SQLite Insert Steps 1. Chunk the list 2. Create

    strings to represent SQL 3. Compile SQLite statements 4. Bind items to the statement 5. Execute the statement
  4. Binding Items 1. Bind each item 2. Track the current

    Bind Index 3. Use the correct typed bind function for each value a. bindString, bindLong ect