Kotlin for Ruby Developers
Move from Ruby to Kotlin through null safety, collection ownership, functions, properties and object contracts. Compare blocks, collections and value models, build an order processor, and port a stock ledger.
Ruby and Kotlin side by side
The same program in Ruby and in Kotlin, from the lessons of this course.
Strings and Templates
Ruby double-quoted strings interpolate braced expressions after a hash sign; Kotlin uses dollar-prefixed names or braced expressions. Ruby puts and Kotlin println add line endings, but their handling of collections differs. Build the required text explicitly…
Ruby1name="Ada"; puts "Hi "+name+" !"Kotlin1fun main(){2val ready=33println("Ready: $ready")4}Equality and Identity
Ruby == is type-defined value equality, equal? checks identity, and eql? participates in Hash key comparison with hash. Kotlin == invokes null-safe equals while === checks identity. Strings compare contents, but ordinary classes default to identity and arrays…
Ruby1a="ab";b="a"+"b";puts(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
Ruby arrays can grow and accept negative indexes measured from the end. Kotlin arrays have fixed size and checked zero-based indexes; a negative index is invalid. IntArray uses primitive integer storage on the JVM. Use last or lastIndex to access the end and…
Ruby1values=[2,4,6];puts values[-1]Kotlin1fun main(){2val a=intArrayOf(4,8,12)3println(a.last())4}While, Break, and Continue
Ruby next skips the rest of an iteration and break exits traversal. Kotlin uses continue for skipping and break for termination, with Boolean conditions. Advance a manual cursor on every continuing path and check a sentinel before processing it. Do not…
Ruby1n=3;while n>1;n-=1;end;puts nKotlin1fun 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
Ruby def creates methods, while lambdas and procs are callable objects with different control-flow rules. Kotlin supports top-level functions with typed parameters and result contracts. A non-Unit block body needs explicit returns; an expression body returns…
Ruby1def hours(total);total/60;end;puts hours(125)Kotlin1fun isLong(text:String):Boolean = text.length>42fun main(){3println(isLong("coffee"))4}Input and String Formatting
Ruby gets returns nil at EOF and chomp removes a line ending; Kotlin readlnOrNull returns null at EOF. Kotlin toInt requires a complete valid integer string, unlike Ruby to_i’s permissive prefix conversion. The task driver owns console I/O, so helpers return…
Ruby1cents=305;puts format("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 Ruby Developers for?
For people who already write Ruby and want to learn Kotlin. Each lesson starts from Ruby 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 Ruby basics: variables, conditions, loops, functions and collections.
How many lessons does Kotlin for Ruby Developers have?
Kotlin for Ruby Developers contains 48 interactive lessons you can complete at your own pace.
What does Kotlin for Ruby 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 Ruby Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.