Menu
CoddyTech
Course

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.

  1. 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…

    Kotlin
    1
    2fun main(){3println("Hi"+", Ada")4}
    Ruby
    1print "oak!"2# A real comment3puts "#seed"
  2. 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…

    Kotlin
    1
    2fun main(){3val wet=false;val label=if(wet) "rain" else "sun";println(label)4}
    Ruby
    1wet = false2icon = if wet3  "umbrella"4else5  "sun"6end7puts icon
  3. Arrays 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…

    Kotlin
    1
    2fun main(){3val values=listOf(4,8);println(values.last());println(values.getOrNull(9)?:"missing")4}
    Ruby
    1values = [4, 8]2puts values[-1]3puts(values[9].nil? ? "missing" : values[9])
  4. 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.…

    Kotlin
    1
    2fun main(){3val a=mutableListOf(1)4val b=a.toMutableList()5b[0]=96println(a[0])7}
    Ruby
    1values = [1, 2, 3]2alias_values = values3values.reverse!4puts alias_values.join(" ")
  5. 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…

    Kotlin
    1object Labels {fun bracket(text:String)="[$text]"}2fun main(){3println(Labels.bracket("ready"))4}
    Ruby
    1module TextTools2  def self.shout(text)3    text.upcase4  end5end6puts TextTools.shout("elm")
  6. 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…

    Kotlin
    1interface 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}
    Ruby
    1class 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 questions

More courses for Kotlin developers

Learn Ruby from another language

Frequently 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.

Coddy programming languages illustration

Start Ruby for Kotlin Developers for free

Get started