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

Let's talk about Kotlin

Arnab Datta
November 20, 2019

Let's talk about Kotlin

This talk was originally given for Javabin and the Oslo Kotlin Meetup group on November 20th, 2019.

The code used in the presentation (along with more advanced examples) can be found at:
https://github.com/arnabkd/kotlin-javabin-demo

Arnab Datta

November 20, 2019
Tweet

More Decks by Arnab Datta

Other Decks in Programming

Transcript

  1. ABOUT ME As a teenager, Arnab dreamt of being a

    standup comedian, but somehow ended up finding the world of programming instead. He can be found coding away on his mac or dancing (sometimes both at the same time). Feel free to grab him and ask him any questions you want, especially about dogs.
  2. KOTLIN WHY AM I SO IN LOVE WITH IT ▸

    First and foremost: fi xes so many of the problems that Java suffered from ▸ Null safety built in the type safety ▸ Just…so many small utilities everywhere ▸ Functions are fi rst class citizens
  3. ▸ let, run, with, apply, also ▸ Key differences ▸

    how they are called ▸ what the context object is called (this vs it) ▸ the return value ▸ Useful for throwaway contextual computations ▸ Read more here SCOPE FUNCTION
  4. ▸ Uses “it” as the receiver argument ▸ Returns the

    last value computed in the lambda ▸ Useful for: conversions from type A to type B LET
  5. ▸ Uses “this” as the receiver argument ▸ Returns the

    last value computed in the lambda ▸ Extremely similar to let ▸ Useful for: when you have side-effects. RUN
  6. ▸ Uses “it” as the receiver argument ▸ Returns Unit

    (regardless of what is computed last) ▸ Useful for: adding log statements after a function returns ALSO
  7. CONTACT INFO AND CODE ▸ Code from the presentation (and

    a bit more) can be found at https:// github.com/arnabkd/kotlin-javabin-demo ▸ Contact me at [email protected] or tweet me @arnab_travels