560 blogs tracked4,950 posts indexed

#article

42 posts · 2 companies · newest first

2

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

freearticleexcerpt only · body stays at the source
From the web
3

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

freearticleexcerpt only · body stays at the source
From the web
4

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

freearticleexcerpt only · body stays at the source
From the web
5

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

freearticleexcerpt only · body stays at the source
From the web
6

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

freearticleexcerpt only · body stays at the source
From the web
7

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

freearticleexcerpt only · body stays at the source
From the web
9

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

freearticleexcerpt only · body stays at the source
From the web
10

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

freearticleexcerpt only · body stays at the source
From the web
11

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

freearticleexcerpt only · body stays at the source
From the web
13

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

freearticleexcerpt only · body stays at the source
From the web
14

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

freearticleexcerpt only · body stays at the source
From the web
15

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

freearticleexcerpt only · body stays at the source
From the web
16

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

freearticleexcerpt only · body stays at the source
From the web
17

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

freearticleexcerpt only · body stays at the source
From the web
19

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

freearticleexcerpt only · body stays at the source
From the web
20

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,…

freearticleexcerpt only · body stays at the source
From the web
21

Kodebits Day 82: Stride By Value [FREE] (opens on the source site)

What does this print? let s1 = stride( from: 2, to: 10, by: 3 ) for i in s1 { print(i, terminator: " ") } print() let s2 = stride( from: 12, through: 6, by: -2 ) for i in s2 { print(i, terminator: " ") } Try it in the online Swift Playground → [spoiler title="Solution"] Answer: 2 5 8 12 10 8 6 Explanation: stride generates sequences with custom steps; to excludes end, through includes it. [/spoiler] Further Reading Swift Apprentice Fundamentals Swift Cookbook

freearticleexcerpt only · body stays at the source
From the web
22

Kodebits Day 81: Guard Multiple Bindings [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 iOS ● ○ ○ Swift 6 Aug 25 2026 Practice guard with a short swift 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, Swift, Android,…

freearticleexcerpt only · body stays at the source
From the web
23

Kodebits Day 80: Safe Call Operator [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 23 2026 Practice null-safety 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,…

freearticleexcerpt only · body stays at the source
From the web
24

Kodebits Day 79: Collection If [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 Flutter ● ○ ○ Aug 20 2026 Practice collection if with a short dart 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, Swift,…

freearticleexcerpt only · body stays at the source
From the web
25

Kodebits Day 78: Switch Where Clause [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 iOS ● ● ○ Swift 6 Aug 18 2026 Practice switch statements with a short swift 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,…

freearticleexcerpt only · body stays at the source
From the web
26

Kodebits Day 77: Optional flatMap [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 iOS ● ● ○ Swift 6 Aug 17 2026 Practice optionals with a short swift 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, Swift,…

freearticleexcerpt only · body stays at the source
From the web
27

Kodebits Day 76: Elvis Operator [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 15 2026 Practice null-safety 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,…

freearticleexcerpt only · body stays at the source
From the web
28

Kodebits Day 75: Range Iteration [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 iOS ● ○ ○ Swift 6 Aug 13 2026 Practice ranges with a short swift 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, Swift,…

freearticleexcerpt only · body stays at the source
From the web
29

Kodebits Day 74: Lateinit Property [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 12 2026 Practice lateinit 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,…

freearticleexcerpt only · body stays at the source
From the web
30

Kodebits Day 73: String Template [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 10 2026 Practice strings 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,…

freearticleexcerpt only · body stays at the source
From the web
31

Kodebits Day 72: Late Variable Init [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 Flutter ● ● ○ Aug 8 2026 Practice late variables with a short dart 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, Swift,…

freearticleexcerpt only · body stays at the source
From the web
32

Kodebits Day 71: Value vs Reference [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 iOS ● ● ○ Swift 6 Aug 7 2026 Practice value semantics with a short swift 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, Swift,…

freearticleexcerpt only · body stays at the source
From the web
33

Kodebits Day 70: Range Progression [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 5 2026 Practice ranges 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, Swift,…

freearticleexcerpt only · body stays at the source
From the web
34

Kodebits Day 69: Spread Copy Independence [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 Flutter ● ● ● Aug 3 2026 Practice collections with a short dart 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, Swift, Android,…

freearticleexcerpt only · body stays at the source
From the web
35

Kodebits Day 68: Zip Collections [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 2 2026 Practice collections 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,…

freearticleexcerpt only · body stays at the source
From the web
42 shown

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.