1 of 18

Nicolas Mouchel

Tech lead Android

@_sagix

2 of 18

Premier pas

3 of 18

Online

Kotlin playground

https://play.kotlinlang.org/

4 of 18

Online

Try kotlin

https://try.kotlinlang.org/

5 of 18

IDE

EduTools

https://kotlinlang.org/docs/tutorials/edu-tools-learner.html

6 of 18

REPL - Read–eval–print loop

7 of 18

Script

8 of 18

Scratch

⇧⌘N

9 of 18

Tests unitaires

@get:Rule val rule: MockitoRule = MockitoJUnit.rule()

@Mock private lateinit var featureCallback: () -> Unit

@Mock private lateinit var onboardingCallback: () -> Unit

@Mock private lateinit var state: InboxInvitationsState

@InjectMock private lateinit var guide: InboxInvitationsBreakerGuide

@Before fun setUp() {

[...]

}

@Test fun `Given never displayed, then redirected to onBoarding`() {

given(state.lastTimeInvitationOnboardingDisplayed).willReturn(null)

guide.guideToNextScreen(onboardingCallback, featureCallback)

then(onboardingCallback).should().invoke()

}

10 of 18

A éviter

  • Kotlin native
  • Kotlin javascript
  • Kotlin multi-platform

11 of 18

Erreurs à éviter

12 of 18

Convert Java File to Kotlin File

Good Java

~Good Kotlin

convert

Bad Java

Bad Kotlin

convert

13 of 18

Bang!!

The operator for NPE-lovers

!!

14 of 18

Interopérabilité Java kotlin

String!

Bang!!

15 of 18

Interopérabilité Java kotlin

String?

16 of 18

lateinit

Bang!!

17 of 18

Lambda of hell

18 of 18

Questions ?: “Thank you”