CodeGym
AI Academy
Promotion
CodeGym University
Learning
Courses
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme

Lessons

  • Reviews
  • About us
Start
Start learning
Start learning now
  • My Progress
  • Courses
  • University
  • Quest Map
  • Lessons
  • forEach and side effects: when this is appropriate

    Kotlin SELF
    Level 22, Lesson 0
    We break down how forEach differs from the for loop in Kotlin: why forEach is a function, why it returns Unit, where side effects (printing, logging, function calls) are appropriate, and where it is better to choose collection transformations. We also look at convenient patterns like ?. forEach for nullable collections, the callable reference :: println, and common mistakes: expecting a “result”, accumulating hidden state, and trying to use break/ continue.
    Available
  • map and filter — transformation and selection as a baseline style

    Kotlin SELF
    Level 22, Lesson 1
    We break down the basic “pipeline” style of working with collections in Kotlin: how map() turns each element into a new value, how filter() keeps only the matching elements, why these operations create a new result (and do not mutate the original collection), how to read chains of steps and choose the right order of transformations. At the end — a practical CLI example and a review of typical mistakes (side effects, the wrong return type from a lambda, overly long lambdas).
    Available
  • find/any/all/count: searching, checks, and counting without manual loops

    Kotlin SELF
    Level 22, Lesson 2
    We break down the standard Kotlin operations on collections — find, any, all, count: how to find the first matching element and work with a nullable result ( T ?), how “at least one” and “all” checks differ, why all on an empty list returns true, and how to write remove/ stats commands in a CLI without manual loops, flags, or extra counters.
    Available
  • mapNotNull and filterNotNull: cleaning data and changing types

    Kotlin SELF
    Level 22, Lesson 3
    We break down how to remove null from collections in Kotlin and simultaneously “fix” types: how mapNotNull differs from the map + filterNotNull combination, why toIntOrNull() pairs perfectly with mapNotNull, how to get a List<Int> instead of a List<Int?>, and how to build robust processing pipelines for “dirty” input without extra checks.
    Available
  • Readable operation chains: results without mutating the original collection

    Kotlin SELF
    Level 22, Lesson 4
    We break down how to build data-processing “pipelines” over collections in Kotlin without mutating the original list: combine map/ filter/ mapNotNull, finish chains with find/ any/ all/ count, separate computation from printing (keeping forEach for the very end), and learn to “break” long chains with intermediate val for readability. In the examples: a mini-project for expenses using Triple, input normalization, and safe work with null.
    Available
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning, and a Java developer’s career.
Follow us
Interface language
English
Deutsch Español हिन्दी Français Português Polski বাংলা 简体中文 मराठी தமிழ் Italiano Bahasa Indonesia 繁體中文 Nederlands 日本語 한국어 Bulgarian Danish Hungarian Basa Jawa Malay Norwegian Romanian Swedish Telugu Thai Українська Filipino Turkish Azərbaycan Русский Vietnamese
Programmers Are Made, Not Born © 2026 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2026 CodeGym