This Week I Learned: Kotlin’s when is neat [2022–02–28]

  • the -> feels like the nicest syntaxes of functional programming
  • the else is optional if the conditions exhaustively test all values
  • my IDE complains if I omit the else and I haven’t tested all values, and otherwise let’s me omit it
  • multiple values can be grouped together by putting commas between them
  • in and is read especially fluently (when foo in bah…)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Peter Brownlow

Peter Brownlow

18 Followers

Software builder, people manager, technical deep-dive enthusiast