Ruby for Kotlin Developers
Move from Kotlin to Ruby through 48 multi-file tasks covering flow, blocks, collections, errors, classes, modules and inheritance. Build a lending desk and port two complete source programs.
Kotlin and Ruby side by side
The same program in Kotlin and in Ruby, from the lessons of this course.
Output and Comments
Kotlin println and Ruby puts append a newline to ordinary text output. Kotlin entry functions run compiled code, while Ruby executes top-level statements and loads neighboring files with require_relative. Kotlin packages and imports organize declarations…
Kotlin1 2fun main(){3println("Hi"+", Ada")4}Ruby1print "oak!"2# A real comment3puts "#seed"Conditional Values
Kotlin if and Ruby if both produce a selected branch value. Kotlin requires else when if is used as a value and applies static type rules; Ruby can yield nil when no branch matches. Ruby conditions use truthiness rather than Boolean-only predicates. Preserve…
Kotlin1 2fun main(){3val wet=false;val label=if(wet) "rain" else "sun";println(label)4}Ruby1wet = false2icon = if wet3 "umbrella"4else5 "sun"6end7puts iconArrays and Indexing
Kotlin List indexing throws for an invalid index; getOrNull returns null and last selects the final element. Ruby ordinary indexing returns nil for absence, and negative indexes count from the end. Ruby fetch can raise when absence is exceptional. A Kotlin…
Kotlin1 2fun main(){3val values=listOf(4,8);println(values.last());println(values.getOrNull(9)?:"missing")4}Ruby1values = [4, 8]2puts values[-1]3puts(values[9].nil? ? "missing" : values[9])Mutation and Aliases
Kotlin assignment shares a collection, while toMutableList creates separate outer storage. Ruby assignment aliases an array, reverse! mutates it and reverse creates another array. Kotlin val prevents rebinding instead of freezing the referenced collection.…
Kotlin1 2fun main(){3val a=mutableListOf(1)4val b=a.toMutableList()5b[0]=96println(a[0])7}Ruby1values = [1, 2, 3]2alias_values = values3values.reverse!4puts alias_values.join(" ")Modules as Namespaces
Kotlin packages, imports and object declarations organize compiled names and singleton helpers. Ruby modules group constants and methods at runtime, with require_relative loading files. A Ruby filename creates no namespace automatically. Ruby include…
Kotlin1object Labels {fun bracket(text:String)="[$text]"}2fun main(){3println(Labels.bracket("ready"))4}Ruby1module TextTools2 def self.shout(text)3 text.upcase4 end5end6puts TextTools.shout("elm")Composing Objects
Kotlin and Ruby class instances can retain collaborators without cloning them or transferring exclusive ownership. Kotlin interfaces specify nominal contracts, while Ruby commonly calls compatible methods dynamically. Delegation supports variation without…
Kotlin1interface Policy {fun apply(n:Int):Int}2class DoublePolicy:Policy {override fun apply(n:Int)=n*2}3class Order(val policy:Policy){fun total()=policy.apply(3)}4fun main(){5val order=Order(DoublePolicy())6println(order.total())7}Ruby1class Lens2 def label; "wide"; end3end4class Camera5 def initialize(lens); @lens = lens; end6 def label; @lens.label; end7end8puts Camera.new(Lens.new).label
Syllabus
9 chapters48 lessons1 project48 challenges99 quiz questionsStart with Ruby
8 lessonsFlow and Methods
6 lessonsCollections and Blocks
6 lessonsMutation and Errors
5 lessonsObjects and State
5 lessonsComposition and Dispatch
6 lessonsObjects in Practice
6 lessonsLending Desk Project
4 lessonsPort Kotlin Programs
2 lessonsFrequently asked questions
Who is Ruby for Kotlin Developers for?
For people who already write Kotlin and want to learn Ruby. Each lesson starts from Kotlin you know and shows how Ruby does the same thing, so you skip the beginner basics.
Do I need to know Ruby already?
No. The course starts with your first Ruby program. You need Kotlin basics: variables, conditions, loops, functions and collections.
How many lessons does Ruby for Kotlin Developers have?
Ruby for Kotlin Developers contains 48 interactive lessons you can complete at your own pace.
What does Ruby for Kotlin Developers cover?
The course is organized into chapters covering: Start with Ruby, Flow and Methods, Collections and Blocks, Mutation and Errors, and more.
Is Ruby for Kotlin Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.