Kodebits reached Day 100 on 30 September, and we’re pausing to take stock. Here are September’s 15 bits grouped by platform and difficulty, a look back at the full hundred, and a chance to tell us what you’d change.
What is the output? enum Direction { case north, south, east, west } let d = Direction.north if d == .north { print("Go up") } else { print("Other way") } [spoiler title="Solution"] Answer: Go up Explanation: Enums define groups of related values; dot syntax matches cases. [/spoiler] Further Reading Swift Apprentice Fundamentals Introduction to Object-Oriented Programming
What does this print? tailrec fun rev( s: String, acc: String = "" ): String { return if (s.isEmpty()) acc else rev(s.drop(1), s[0] + acc) } fun main() { println(rev("code")) } [spoiler title="Solution"] Answer: edoc Explanation: tailrec optimizes tail-recursive calls into loops, preventing stack overflow. Here, each character is prepended to the accumulator while dropping from the original string. [/spoiler] Further Reading Advanced Kotlin Class Features Advanced OOP in Kotlin
What is the output? let items = ["A", "B", "C"] for (i, v) in items.enumerated() { print("\(i):\(v)") } Try it in the online Swift Playground → [spoiler title="Solution"] Answer: 0:A 1:B 2:C Explanation: enumerated provides both index and value when iterating collections. [/spoiler] Further Reading Swift Apprentice Fundamentals Swift Cookbook
What is the output? fun total(vararg nums: Int): Int { return nums.sum() } fun main() { println(total(2, 4, 6, 8)) } Try it in the online Kotlin Playground → [spoiler title="Solution"] Answer: 20 Explanation: vararg allows passing variable number of arguments as an array. [/spoiler] Further Reading Utilize Control Flow in Kotlin Learn the Basics of the Kotlin Language
What is the output? fun main() { val s = (1..6).asSequence() .map { it * 2 } .filter { it > 5 } .take(2) println(s.toList()) } Try it in the online Kotlin Playground → [spoiler title="Solution"] Answer: [6, 8] Explanation: Sequences evaluate lazily, processing elements one at a time. [/spoiler] Further Reading Use Kotlin Classes Introduction to Kotlin OOP
What does this print? struct Point { var x: Int, y: Int static func + ( a: Point, b: Point ) -> Point { Point( x: a.x + b.x, y: a.y + b.y ) } } let p = Point(x: 2, y: 3) + Point(x: 4, y: 5) print("\(p.x),\(p.y)") Try it in the online Swift Playground → [spoiler title="Solution"] Answer: 6,8 Explanation: Operator overloading customizes how operators work with custom types. [/spoiler] Further Reading Expert Swift Swift Apprentice Beyond the Basics
What does this print? func greet( _ name: String, times: Int = 1 ) { for _ in 0..<times { print("Hi \(name)") } } greet("Alice") greet("Bob", times: 2) Try it in the online Swift Playground → [spoiler title="Solution"] Answer: Hi Alice Hi Bob Hi Bob Explanation: Default parameters provide fallback values when arguments are omitted. [/spoiler] Further Reading Swift Apprentice Fundamentals Swift Apprentice Beyond the Basics
What is the output? void main() { final nums = [1, 2, 3]; final out = [ for (var n in nums) n * 2 ]; print(out.length + out[0]); } Try it in the online Dart Playground → [spoiler title="Solution"] Answer: 5 Explanation: A collection for builds a new list by transforming each source item. [/spoiler] Further Reading Programming in Dart: Fundamentals Programming in Dart: Control Flow & Collections
What does this print? struct Counter { var value: Int = 0 { didSet { print("Set to \(value)") } } } var c = Counter() c.value = 5 c.value = 8 Try it in the online Swift Playground → [spoiler title="Solution"] Answer: Set to 5 Set to 8 Explanation: didSet observers run after a property value changes. [/spoiler] Further Reading Swift Apprentice Fundamentals Object-Oriented Programming Beyond the Basics
Swift Testing is Apple’s replacement for the objective-C XCTest unit testing framework. Discover how to migrate your existing XCTest suites over to Swift Testing, including how to get some assistance from Xcode’s agentic AI tooling.
What does this print? fun calc( a: Int, b: Int, op: String ): Int { return if (op == "+") a + b else a - b } fun main() { println(calc( b = 5, a = 3, op = "+" )) println(calc( op = "?", a = 3, b = 5 )) } Try it in the online Kotlin Playground → [spoiler title="Solution"] Answer: 8 -2 Explanation: Named arguments allow reordering and clarity. [/spoiler] Further Reading Advanced OOP in Kotlin Introduction to Kotlin OOP
What is the output? enum Status: Int { case pending = 1 case active = 5 case done = 10 } let s = Status.active print(s.rawValue) print(Status.done.rawValue) Try it in the online Swift Playground → [spoiler title="Solution"] Answer: 5 10 Explanation: Raw values provide underlying primitive values for enum cases. [/spoiler] Further Reading Swift Apprentice Fundamentals Swift Apprentice Beyond the Basics
What is the output? func double(_ n: inout Int) { n *= 2 } var x = 5 double(&x) print(x) var y = 10 double(&y) print(y) Try it in the online Swift Playground → [spoiler title="Solution"] Answer: 10 20 Explanation: inout parameters allow functions to modify the original variable. [/spoiler] Further Reading Swift Apprentice Fundamentals Swift Apprentice Beyond the Basics
What is the output? fun greet( name: String = "Guest" ) = "Hi, $name" fun main() { println(greet("Edith")) println(greet()) } Try it in the online Kotlin Playground → [spoiler title="Solution"] Answer: Hi, Edith Hi, Guest Explanation: Default parameters provide values when arguments aren’t supplied. [/spoiler] Further Reading Leverage Kotlin Functions & Lambdas Utilize Control Flow in Kotlin
What is the output? struct Rect { var width: Int var height: Int var area: Int { return width * height } } let r = Rect(width: 4, height: 5) print(r.area) Try it in the online Swift Playground → [spoiler title="Solution"] Answer: 20 Explanation: Computed properties calculate values on access rather than storing them. [/spoiler] Further Reading Swift Apprentice Fundamentals Object-Oriented Programming Beyond the Basics
Kotlin outnumbered Swift for the first time in August, and the month eased off after July’s hard streak. Here’s all 18 bits grouped by platform and sorted from beginner to advanced.
What does this print? fun main() { val x: Any = 42 val n = x as Int println(n * 2) } Try it in the online Kotlin Playground → [spoiler title="Solution"] Answer: 84 Explanation: as explicitly casts a value to the specified type. [/spoiler] Further Reading Advanced Kotlin Class Features Utilize Control Flow in Kotlin
Open menu The new raywenderlich.com Open menu The new raywenderlich.com Learn Pricing For Teams Resources Search Toggle night mode Android ● ● ○ Kotlin 2.0 Aug 28 2026 Practice type checks with a short kotlin challenge. About Kodebits Kodebits are bite-sized insights, tips, and code snippets from the Kodeco team. Designed to help you learn something new in just a few minutes. They appear first on social media, so be sure to follow us there! Or view the archive here. All videos. All books. One low price. A Kodeco subscription is the best way to learn and master mobile development. Learn iOS,…
Read at the source
Your visit, your choice.
Optional Google Analytics helps us understand visits. Microsoft Clarity records masked interactions to improve the site. Optional tools stay off unless you choose them. Privacy details.