Skip to content

Kotlin Basics Flashcards - Wyatt's Notes

Kotlin Basics Flashcards

15 flashcards covering core Kotlin concepts. Tap a card to reveal the answer.


Intuition

Kotlin is a modern JVM language that eliminates Java’s verbosity while maintaining full interoperability. Null safety is built into the type system — String is non-null, String? is nullable, and the compiler enforces checks. Extension functions let you add methods to existing classes without modifying them, and scope functions (let, run, with, apply, also) provide concise ways to work with objects in context.

How to Use These Flashcards

First pass: Go through all 15 cards without rating — just flip and read. This familiarises you with the content and identifies weak areas.

Interoperability practice: After reviewing a card, consider how the Kotlin concept maps to Java equivalent. Kotlin-Java interop is a common interview topic.

Android connection: If you’re learning Kotlin for Android, relate each concept to its Android use case — coroutines for async, sealed classes for UI state, extension functions for utility methods.

Common Pitfalls

  • !! operator overuse: The not-null assertion (!!) throws a NullPointerException if the value is null — prefer safe calls (?.) or let blocks.
  • Sealed class exhaustiveness: Forgetting to handle all cases in a when expression on a sealed class — the compiler catches this if you omit the else branch, but only for sealed hierarchies.
  • Coroutine scope leaks: Launching coroutines in the wrong scope (e.g., GlobalScope.launch) — always use structured concurrency with viewModelScope or lifecycleScope.
  • Data class copy陷阱: Forgetting that copy() does a shallow copy — nested mutable objects are still shared references between original and copy.
  • Inline function misuse: Marking functions as inline unnecessarily increases code size. Only inline functions with lambda parameters to avoid the overhead of creating Function objects.

Study Tips

  • Use IntelliJ’s Kotlin REPL: The built-in REPL lets you test Kotlin expressions interactively. This is faster than writing a full program for quick experiments.
  • Practise null safety patterns: Write functions that accept both nullable and non-nullable parameters. Use ?.let {}, ?:, and if-else to handle null cases gracefully.
  • Study the Kotlin standard library: Functions like also, let, run, apply, and with are concise but powerful. Understanding when to use each one is key to idiomatic Kotlin.
  • Build a small Android app: If learning Kotlin for Android, create a simple app that demonstrates coroutines, sealed classes for UI state, and extension functions for utility methods.
  • Explore Kotlin Playground: The online Kotlin Playground (play.kotlinlang.org) lets you experiment with Kotlin code interactively without installing anything.
  • Study coroutines deeply: Kotlin coroutines are essential for async programming. Understand structured concurrency, scope functions, and flow for building responsive applications.

See Also

Detailed Content

This topic covers the fundamental principles and applications in depth. Each concept is explained with clear definitions, worked examples, and practice problems to reinforce understanding.

Core Concepts

Understanding these core concepts is essential for mastering this topic. They form the foundation for more advanced study and are frequently examined.

Worked Examples

Worked examples demonstrate how to apply the concepts to solve problems. Each example is broken down into clear steps with explanations.

Common Mistakes

  • Rushing through foundational material
  • Not practising problems after reading
  • Failing to connect concepts across topics

Further Reading

Consult the recommended textbooks and additional resources for deeper understanding of this topic.

Detailed Content

This topic covers the fundamental principles and applications in depth. Each concept is explained with clear definitions, worked examples, and practice problems to reinforce understanding.

Core Concepts

Understanding these core concepts is essential for mastering this topic. They form the foundation for more advanced study and are frequently examined.

Worked Examples

Worked examples demonstrate how to apply the concepts to solve problems. Each example is broken down into clear steps with explanations.

Common Mistakes

  • Rushing through foundational material
  • Not practising problems after reading
  • Failing to connect concepts across topics

Further Reading

Consult the recommended textbooks and additional resources for deeper understanding of this topic.

Detailed Content

This topic covers the fundamental principles and applications in depth. Each concept is explained with clear definitions, worked examples, and practice problems to reinforce understanding.

Core Concepts

Understanding these core concepts is essential for mastering this topic. They form the foundation for more advanced study and are frequently examined.

Worked Examples

Worked examples demonstrate how to apply the concepts to solve problems. Each example is broken down into clear steps with explanations.

Common Mistakes

  • Rushing through foundational material
  • Not practising problems after reading
  • Failing to connect concepts across topics

Further Reading

Consult the recommended textbooks and additional resources for deeper understanding of this topic.

Detailed Content

This topic covers the fundamental principles and applications in depth. Each concept is explained with clear definitions, worked examples, and practice problems to reinforce understanding.

Core Concepts

Understanding these core concepts is essential for mastering this topic. They form the foundation for more advanced study and are frequently examined.

Worked Examples

Worked examples demonstrate how to apply the concepts to solve problems. Each example is broken down into clear steps with explanations.

Common Mistakes

  • Rushing through foundational material
  • Not practising problems after reading
  • Failing to connect concepts across topics

Further Reading

Consult the recommended textbooks and additional resources for deeper understanding of this topic.

Detailed Content

This topic covers the fundamental principles and applications in depth. Each concept is explained with clear definitions, worked examples, and practice problems to reinforce understanding.

Core Concepts

Understanding these core concepts is essential for mastering this topic. They form the foundation for more advanced study and are frequently examined.

Worked Examples

Worked examples demonstrate how to apply the concepts to solve problems. Each example is broken down into clear steps with explanations.

Common Mistakes

  • Rushing through foundational material
  • Not practising problems after reading
  • Failing to connect concepts across topics

Further Reading

Consult the recommended textbooks and additional resources for deeper understanding of this topic.