JavaRush
AI Academy
new
Promotion
Learning
Courses
Tasks
Quizzes
Games
Help
Schedule of nudges
Internship
Community
Users
Forum
Chat
Articles
Success stories
Activities
Reviews
Subscriptions
Light theme

Lectures

  • Reviews
  • About us
  • CS50
Start
Start learning
Start learning
  • My progress
  • Courses
  • Quest map
  • Lectures
  • `enum class`: values, parameters, methods, and declaration rules

    Kotlin SELF
    34 level,0 lecture
    We break down why Kotlin needs enum class instead of “magic strings”: type-safe values (for example, Status.DONE), standard properties name and ordinal (and why you must not use ordinal as a stable identifier), getting all options via entries, strict parsing via valueOf, as well as enums with parameters and methods (and the mandatory ; before the body). At the end — a practical example for console expense tracking and common mistakes.
    Open
  • when with enum — exhaustive branches and when as an expression

    Kotlin SELF
    34 level,1 lecture
    We break down how to use when with enum in Kotlin so that the compiler checks branch completeness: why an exhaustive when is better written without else, how to turn branching into a “mapping table”, how when works as an expression (returns a value), what happens to the result type, and how to correctly handle null for a nullable enum ( E?).
    Open
  • Getting to know sealed class

    Kotlin SELF
    34 level,2 lecture
    We break down how sealed hierarchies differ from enum class, and why sealed class is an ideal tool for modeling an “operation result” without null and “magic strings”. We will assemble a minimal CommandResult model with Ok/ Error variants, apply it in a CLI expense-tracker example, and discuss common design mistakes when modeling sealed results.
    Open
  • Type checks and casts: is, smart cast, as, as?

    Kotlin SELF
    34 level,3 lecture
    We break down how to safely work with “general” types in Kotlin: checking a type with is/ !is, getting a smart cast (including in Kotlin 2.x with the K2 compiler), and also how unsafe casting as differs from safe casting as? when paired with the Elvis operator ?:. At the end: a practical example of parsing an amount from Any?, a mermaid diagram, and typical mistakes.
    Open
  • sealed and when: Ok / Error style and exhaustive handling

    Kotlin SELF
    34 level,4 lecture
    We break down a practical pattern for a Kotlin CLI application: a single command result via a sealed hierarchy CommandResult ( Ok/ Error), returning results from business functions without println (), and a message “dispatcher” via an exhaustive when without else. Separately, we show separation of responsibilities: handleCommand does the work, render formats, main outputs.
    Open
Learn
  • Registration
  • Java course
  • Help with tasks
  • Pricing
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success stories
  • Activities
Company
  • About us
  • Contacts
  • Reviews
  • FAQ
  • Support
JavaRushJavaRush — is an interactive online course for learning Java programming from scratch. It contains 1200 practical tasks with one-click solution checking, the necessary minimum of theory on Java basics, and motivating features that help you complete the course: games, quizzes, interesting projects and articles on effective learning and the career of a Java developer.
Follow us
Язык интерфейса
Русский
English
Українська
"Programmers are not born" © 2026 JavaRush
MastercardVisa
"Programmers are not born" © 2026 JavaRush