Kotlin for Swift Developers
Move from Swift to Kotlin through null safety, collection ownership, functions, properties and object contracts. Build a connected multi-file order processor and port a stock ledger.
Swift and Kotlin side by side
The same program in Swift and in Kotlin, from the lessons of this course.
Strings and Templates
Swift permits executable top-level statements in main.swift. Kotlin puts executable statements inside a function, with one top-level main in Main.kt. Both languages support interpolation, but Swift uses backslash-parentheses while Kotlin uses dollar…
Swift1let ready = 32print("Ready: \(ready)")Kotlin1fun main(){2val ready=33println("Ready: $ready")4}Equality and Identity
Swift String equality and Kotlin String equality compare contents. Swift reference identity uses === on class instances, while Kotlin === distinguishes references independently of equals. Swift structs can synthesize Equatable; an ordinary Kotlin class does…
Swift1let a = String(["t", "e", "a"])2let b = "tea"3print(a == b)Kotlin1fun main(){2val a=String(charArrayOf('t','e','a'))3val b=String(charArrayOf('t','e','a'))4println(a==b)5}Arrays and IntArray
Swift Array is a growable value type, despite its name. Kotlin Array and IntArray have fixed sizes, and MutableList supplies growth. Swift collection indexes are not uniformly integers for every collection, especially String. This example uses Array indexes…
Swift1let values = [4, 8, 12]2print(values[values.count - 1])Kotlin1fun main(){2val a=intArrayOf(4,8,12)3println(a.last())4}While, Break, and Continue
Swift and Kotlin distinguish break from continue. Swift labeled statements and Kotlin labeled expressions provide related outer-loop control with different syntax. Ensure every continuing path makes progress in a while loop. Here the blank word is skipped…
Swift1var kept = [String]()2for word in ["tea", "", "STOP", "coffee"] {3 if word == "STOP" { break }4 if word.isEmpty { continue }5 kept.append(word)6}7print(kept.joined(separator: ","))Kotlin1fun main(){2val kept=mutableListOf<String>()3for(word in listOf("tea","","STOP","coffee")){if(word=="STOP")break;if(word.isEmpty())continue;kept.add(word)}4println(kept.joinToString(","))5}Top-level Functions
Swift functions can use inout parameters to modify a caller variable. Kotlin ordinary parameters do not offer that rebinding mechanism; return a result or mutate an explicit object when appropriate. Both languages allow top-level helper functions. Swift…
Swift1func isLong(_ text: String) -> Bool { text.count > 4 }2print(isLong("coffee"))Kotlin1fun isLong(text:String):Boolean = text.length>42fun main(){3println(isLong("coffee"))4}Input and String Formatting
Swift Foundation trimmingCharacters uses a character set; Kotlin trim has its own overloads and defaults. Swift String count counts extended grapheme clusters, while Kotlin String length counts UTF-16 code units on the JVM. These ASCII examples avoid…
Swift1import Foundation2print(" tea ".trimmingCharacters(in: .whitespaces).uppercased())Kotlin1fun main(){2println(" tea ".trim().uppercase(java.util.Locale.ROOT))3}
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsStarting Kotlin
6 lessonsValues and Decisions
5 lessonsCollections and Ownership
5 lessonsIteration and Transformations
5 lessonsFunctions and Callbacks
5 lessonsInput, Errors, and Files
5 lessonsClasses and State
6 lessonsComposition and Value Types
5 lessonsProject: Order Processing
4 lessonsFinal Challenges
2 lessonsFrequently asked questions
Who is Kotlin for Swift Developers for?
For people who already write Swift and want to learn Kotlin. Each lesson starts from Swift you know and shows how Kotlin does the same thing, so you skip the beginner basics.
Do I need to know Kotlin already?
No. The course starts with your first Kotlin program. You need Swift basics: variables, conditions, loops, functions and collections.
How many lessons does Kotlin for Swift Developers have?
Kotlin for Swift Developers contains 48 interactive lessons you can complete at your own pace.
What does Kotlin for Swift Developers cover?
The course is organized into chapters covering: Starting Kotlin, Values and Decisions, Collections and Ownership, Iteration and Transformations, and more.
Is Kotlin for Swift Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.