Kotlin for GDScript Developers
Move from GDScript to Kotlin through null safety, collection ownership, functions, properties and object contracts. Compare captures and accessors, build an order processor, and port a stock ledger.
GDScript and Kotlin side by side
The same program in GDScript and in Kotlin, from the lessons of this course.
Strings and Templates
GDScript print and prints differ in argument spacing, and percent formatting assembles strings explicitly. Kotlin string templates interpolate names or expressions and println adds a newline. GDScript String length counts code points, while Kotlin/JVM length…
GDScript1extends Node2 3 4func _ready() -> void:5 var user_name: String = "Ada"6 prints("Hi "+user_name,"!")Kotlin1fun main(){2val ready=33println("Ready: $ready")4}Equality and Identity
GDScript strings compare text and Array or Dictionary equality can compare contents. Kotlin == uses equals and === checks reference identity, but arrays need contentEquals when element equality is intended. Strings have content equality and ordinary classes…
GDScript1extends Node2 3 4func _ready() -> void:5 var a: String = "ab"6 var b: String = "a"+"b"7 print(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
GDScript Array grows dynamically and supports negative indexes. Kotlin arrays instead have fixed size and checked nonnegative indexes. IntArray provides primitive integer storage, while Array<Int> has a different JVM representation. Use last or lastIndex for…
GDScript1extends Node2 3 4func _ready() -> void:5 var values: Array[int] = [2,4,6]6 print(values[-1])Kotlin1fun main(){2val a=intArrayOf(4,8,12)3println(a.last())4}While, Break, and Continue
GDScript and Kotlin both support while, break and continue, but Kotlin requires a Boolean condition. Advance manual indexes on every continuing path and recognize a stop marker before normal processing. Kotlin string == checks content. Keep skipping an empty…
GDScript1extends Node2 3 4func _ready() -> void:5 var n: int = 36 while n>1:7 n-=18 print(n)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
GDScript functions belong to scripts or objects, while Kotlin permits top-level functions in the supplied files. Kotlin parameters are read-only bindings, expression bodies may infer their result type, and non-Unit block bodies need explicit returns.…
GDScript1extends Node2 3static func hours(total: int) -> int:4 return total/605func _ready() -> void:6 print(hours(125))Kotlin1fun isLong(text:String):Boolean = text.length>42fun main(){3println(isLong("coffee"))4}Input and String Formatting
GDScript console input can use OS.read_string_from_stdin, while these Kotlin tasks supply a locked line-reading driver. Kotlin readlnOrNull exposes EOF as null and toInt requires valid complete numeric text. Trim only when allowed and format exact returned…
GDScript1extends Node2 3 4func _ready() -> void:5 var cents: int = 3056 print("tea: %d.%02d" % [cents/100,cents%100])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 GDScript Developers for?
For people who already write GDScript and want to learn Kotlin. Each lesson starts from GDScript 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 GDScript basics: variables, conditions, loops, functions and collections.
How many lessons does Kotlin for GDScript Developers have?
Kotlin for GDScript Developers contains 48 interactive lessons you can complete at your own pace.
What does Kotlin for GDScript 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 GDScript Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.