from/prod
← All companies

THE COMPANY INDEX TRACKED BLOG

Kodeco

Ideas, decisions, and lessons from the team.

raywenderlich.com (opens on the source site)LinkedIn X
41Posts tracked
5 days agoLatest publication
3.0Posts / month over the last 12 months

Latest writing

20 of 41 posts

Kodebits Day 100: Enum Cases [FREE] (opens on the source site)

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

Read at the source

Kodebits Day 99: Tail Recursion [FREE] (opens on the source site)

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

Read at the source

Kodebits Day 97: Enumerated Loop [FREE] (opens on the source site)

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

Read at the source

Kodebits Day 96: Vararg Parameters [FREE] (opens on the source site)

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

Read at the source

Kodebits Day 95: Lazy Sequences [FREE] (opens on the source site)

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

Read at the source

Kodebits Day 94: Operator Overloading [FREE] (opens on the source site)

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

Read at the source

Kodebits Day 93: Default Parameter [FREE] (opens on the source site)

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

Read at the source

Kodebits Day 92: Collection For Loop [FREE] (opens on the source site)

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

Read at the source

Kodebits Day 91: Property Observer [FREE] (opens on the source site)

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

Read at the source

Kodebits Day 90: Named Arguments [FREE] (opens on the source site)

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

Read at the source

Kodebits Day 89: Enum Raw Values [FREE] (opens on the source site)

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

Read at the source

Kodebits Day 88: Inout Parameter [FREE] (opens on the source site)

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

Read at the source

Kodebits Day 87: Default Parameters [FREE] (opens on the source site)

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

Read at the source

Kodebits Day 86: Computed Property [FREE] (opens on the source site)

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

Read at the source

Kodebits Day 85: Type Check As Cast [FREE] (opens on the source site)

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

Read at the source

Kodebits Day 83: Smart Cast [FREE] (opens on the source site)

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

Privacy choices

Reading never requires analytics. These choices last 90 days on this browser.

Essential sign-in and security storage always stays on. Read the privacy notice.