Lesson 2: Kotlin Functions and Classes

Outline:

  1. Questions?
  2. Recap Kotlin basics
    • val versus var
    • when statements
    • for ranges
    • examples: Exercise 1
  3. Functions in Kotlin
    • passing parameters
    • default values
    • returning a value
    • examples: Exercise 2
  4. Classes in Kotlin
    • constructors and init block
    • instance variables
    • methods
    • example: Exercise 3
  5. Wrap-up

What’s next

Upcoming events/assessments:

What you should do now:

  • The readings (see below)
  • Read the syllabus!
  • Complete Part A of Assignment 1 today, and bring questions about Parts B and C to student hours or class Friday

Reading assignment (to be completed by the next class):

Kotlin basics, cont’d (from today):

Kotlin basics, cont’d and Big-O (for next time):