Kodebits: June Roundup

June brought 17 more Kodebits across iOS, Android and Flutter. Here’s the full month grouped by platform and sorted from beginner to advanced — including a strong run of Kotlin’s DSL-building features and a value-semantics thread in Swift. By Sam Davies.

Save for later
Share

Three months in, Kodebits have found their rhythm: small, self-contained coding challenges you can work through between meetings, posted to our social channels as they land and gathered on the Kodebits archive afterwards.

June brought 17 of them across iOS/Swift, Android/Kotlin and Flutter/Dart, and this was the month they started to feel less like isolated tips and more like a connected tour of each language. Swift dug into value semantics and pattern matching, Kotlin worked through the features behind its DSLs, and Dart leaned on modern control flow and collections. It’s all collected below, split by platform and ordered from beginner to advanced, with a note on what each one is good for — and if you’re only now catching up, the first and second months are rounded up the same way.

Each bit is labelled by difficulty: Beginner for an easy warm-up, Intermediate for something to chew on, and Advanced when we’re getting into the deep end.

Each Kodebit page gives you the problem to puzzle over first, then a solution and explanation — plus links into the wider Kodeco catalogue when a topic grabs you and you want to go deeper.

iOS & Swift

Eight Kodebits in June, with a clear thread running through them: value semantics and pattern matching. Structs, tuples, and switch all show up, which together cover a lot of what makes Swift feel different from a reference-heavy language like Java or C#. There’s also a pair on the type system — protocols and type casting — for when you’re ready to move past the fundamentals.

Beginner

  • Day 34: String Interpolation — Embed values directly inside a string literal with \(...). One of the first things you learn in Swift and one of the last you stop appreciating, since it reads so much more cleanly than concatenation.
  • Day 37: Tuple Destructuring — Unpack a tuple’s elements into named constants in a single line. The neat way to handle a function that naturally returns more than one value without reaching for a full struct.
  • Day 39: Struct Value Copy — Structs are value types, so assigning one to a new variable makes a copy. Mutate the copy and the original is untouched. This is the Swift side of the same coin as April’s Kotlin data class copy(), and the foundation for reasoning about state in SwiftUI.
  • Day 49: Variadic Sum — Accept any number of arguments with ... and work with them as an array inside the function. The mechanism behind familiar APIs like print.

Intermediate

  • Day 40: Pattern Match Tuple — Match on the shape of a tuple inside a switch, testing and binding elements in one move. Picks up where May’s enum associated values left off and shows how far Swift’s pattern matching really reaches.
  • Day 44: Protocol Conformance — A look at exactly what a type has to provide to satisfy a protocol. Ties back to April’s protocol extensions: here you meet the requirements, there you supply defaults for them.
  • Day 45: Lazy Property Init — A lazy property defers its work until the first time it’s read, then stores the result. Worth reading right after May’s computed property bit: one recomputes on every access, this one computes once and remembers.
  • Day 47: Type Casting Check — Use is to test a type and as? to downcast safely. Essential whenever you’re working with values whose concrete type isn’t known until runtime.

Android & Kotlin

Six Kodebits in June, and taken together they read like a tour of why Kotlin is so good at building expressive, DSL-style APIs. Infix functions, operator overloading, lambdas with receivers, and delegation are exactly the features behind libraries like Compose and the Gradle Kotlin DSL. If you’ve ever wondered how those libraries read the way they do, this is the month.

Beginner

  • Day 33: Data Class Destructuring — Pull a data class apart into its component values in a single assignment. The natural companion to April’s data class copy() — between them you’ve got most of what makes data classes worth using.

Intermediate

  • Day 35: Companion Object — Kotlin has no static keyword; a companion object is where class-level members and factory methods live instead. The idiomatic home for things you’d reach for statics for elsewhere.
  • Day 38: Infix Function — Mark a function infix and call it without dots or parentheses, so 1 to "one" reads like built-in syntax. A small feature that does a lot of the heavy lifting in Kotlin’s more readable APIs.
  • Day 42: Operator Overloading — Give operators like + and [] meaning for your own types by implementing specially-named functions. Powerful for domain types like vectors or money, and easy to overdo — the bit is a good place to feel out the line.

Advanced

  • Day 36: Lambda With Receiver — A lambda where this refers to a supplied receiver object rather than the enclosing scope. This is the single feature that makes Kotlin DSLs like Compose and buildString possible, so it’s well worth the effort.
  • Day 48: Delegation By Keyword — Use by to hand off interface implementation or property access to another object, no boilerplate forwarding methods required. Composition over inheritance, baked into the language.

Flutter & Dart

Three Kodebits in June, skewing a little harder than usual. We look at Dart’s switch expressions (a genuinely modern take on control flow), a collection filter-and-aggregate chain, and extension methods — the Dart counterpart to the Kotlin extension functions we covered back in May.

Intermediate

  • Day 43: Where Then Fold — Chain where to filter a collection and fold to reduce it to a single value. The Dart expression of a pattern you’ve now seen across all three languages: describe the transformation, don’t hand-roll the loop.
  • Day 46: Extension Method — Add methods to existing types from outside the class. If May’s Kotlin extension function bit clicked, this is the same idea in Dart — handy for seeing which concepts genuinely travel between languages.

Advanced

  • Day 41: Switch Expression — Dart’s switch can be used as an expression that returns a value, complete with pattern matching. A big step up from the C-style switch, and one of the nicer additions in recent Dart versions.