Menu
CoddyTech
Course

Ruby for Dart Developers

Move from Dart 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.

Dart and Ruby side by side

The same program in Dart and in Ruby, from the lessons of this course.

  1. Output and Comments

    Dart begins in main and print adds a newline; Ruby runs top-level statements and puts similarly prints ordinary text with a newline. Ruby require_relative loads neighboring source files, while Dart imports declare library dependencies. Keep the entry point’s…

    Dart
    1
    2void main() {3print("Hi" + ", Ada");4}
    Ruby
    1print "oak!"2# A real comment3puts "#seed"
  2. Conditional Values

    Dart if is a statement and the conditional operator selects a value. Ruby if itself yields the chosen branch value, and postfix conditionals are also available. Ruby conditions use truthiness rather than requiring bool. Preserve an explicit Dart comparison…

    Dart
    1
    2void main() {3const wet=false;final label=wet?"rain":"sun";print(label);4}
    Ruby
    1wet = false2icon = if wet3  "umbrella"4else5  "sun"6end7puts icon
  3. Arrays and Indexing

    Dart List may be growable or fixed-length, and invalid indexes throw RangeError. Ruby arrays are growable, ordinary missing reads return nil and negative indexes count from the end. Dart uses last or an explicit valid index for the final element. Use Ruby…

    Dart
    1
    2void main() {3final values=[4,8];print(values.last);print(values.length>9?values[9]:"missing");4}
    Ruby
    1values = [4, 8]2puts values[-1]3puts(values[9].nil? ? "missing" : values[9])
  4. Mutation and Aliases

    Dart list assignment shares an object, while List.of creates a separate outer list; Ruby assignment likewise aliases an array. Ruby reverse! mutates and reverse returns another array. Dart final prevents rebinding but allows mutation of a mutable list.…

    Dart
    1
    2void main() {3final a=[1]; final b=List<int>.of(a); b[0]=9; print(a[0]);4}
    Ruby
    1values = [1, 2, 3]2alias_values = values3values.reverse!4puts alias_values.join(" ")
  5. Modules as Namespaces

    Dart libraries and imports organize statically resolved declarations, and underscore names are private to their library. Ruby modules organize constants and methods at runtime, with require_relative loading neighboring files. A Ruby filename does not create a…

    Dart
    1String bracket(String text)=>"[$text]";2void main() {3print(bracket("ready"));4}
    Ruby
    1module TextTools2  def self.shout(text)3    text.upcase4  end5end6puts TextTools.shout("elm")
  6. Composing Objects

    Dart and Ruby can retain references to collaborators without cloning them or transferring exclusive ownership. Dart classes supply implicit interfaces and explicit implements contracts, while Ruby commonly uses compatible methods dynamically. Delegation…

    Dart
    1abstract interface class Policy {int apply(int n);}2class DoublePolicy implements Policy {int apply(int n)=>n*2;}3class Order {final Policy policy; Order(this.policy); int total()=>policy.apply(3);}4void main() {5final order=Order(DoublePolicy()); print(order.total());6}
    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 Dart developers

Learn Ruby from another language

Frequently asked questions

Who is Ruby for Dart Developers for?

For people who already write Dart and want to learn Ruby. Each lesson starts from Dart 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 Dart basics: variables, conditions, loops, functions and collections.

How many lessons does Ruby for Dart Developers have?

Ruby for Dart Developers contains 48 interactive lessons you can complete at your own pace.

What does Ruby for Dart 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 Dart 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 Dart Developers for free

Get started