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

Everyday Kotlin

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers. →
Avatar for Rene Rene
August 24, 2017

Everyday Kotlin

A collection of little things that stand

Avatar for Rene

Rene

August 24, 2017

Other Decks in Programming

Transcript

  1. Nullability • Natural next step after @NonNull and @Nullable •

    Your new BFF’s: late init, smart cast, guard
  2. smart cast • You checked already, so get on with

    it • Query returns @Nullable Cursor 
 Which in Kotlin terms is Cursor? 
 Smart cast casts this to Cursor
 (Which in Java would be @Nonnull Cursor)

  3. Mockito - Final • Mocking final classes needs some magic

    • Recent Mockito allow final mocking
  4. Mockito/Hamcrest - Syntax • Function name when clashes with keyword

    • Function name is clashes with keyword • Using back ticks
  5. any()-matcher • java.lang.IllegalStateException: ArgumentMatchers.any() must not be null • Roll

    a NonNull variant • Some Kotlin specific high-level Mockito methods
 https://github.com/nhaarman/mockito-kotlin