Ruby for TypeScript Developers
Move from TypeScript 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.
TypeScript and Ruby side by side
The same program in TypeScript and in Ruby, from the lessons of this course.
Output and Comments
TypeScript adds static checking while the chosen runtime provides output APIs. In Node, console.log adds a newline and process.stdout.write allows exact text, like Ruby puts and print respectively. TypeScript uses slash comments while Ruby uses a hash sign…
TypeScript1export {};2process.stdout.write("oak!");3// A comment4console.log("#seed");Ruby1print "oak!"2# A real comment3puts "#seed"Conditional Values
TypeScript uses a conditional expression to select a value, while Ruby if itself yields its chosen branch result. TypeScript applies static type rules and narrowing; Ruby determines behavior dynamically when the result is used. Only the selected branch…
TypeScript1export {};2const wet:boolean=false;const label=wet?"rain":"sun";console.log(label);Ruby1wet = false2icon = if wet3 "umbrella"4else5 "sun"6end7puts iconArrays and Indexing
TypeScript arrays use zero-based indexes; a missing runtime read yields undefined and at supports negative offsets. Static indexing safety depends on compiler options, while Ruby ordinary missing reads yield nil and negative bracket indexes count from the…
TypeScript1export {};2const values:number[]=[4,8];console.log(values.at(-1));console.log(values[9]===undefined?"missing":values[9]);Ruby1values = [4, 8]2puts values[-1]3puts(values[9].nil? ? "missing" : values[9])Mutation and Aliases
TypeScript array assignment shares an object reference, as Ruby array assignment does. TypeScript reverse mutates, while Ruby reverse! mutates and reverse returns another array. Const prevents rebinding and readonly limits checked operations rather than…
TypeScript1export {};2const values:number[]=[1,2,3];const alias=values;values.reverse();console.log(alias.join(" "));Ruby1values = [1, 2, 3]2alias_values = values3values.reverse!4puts alias_values.join(" ")Modules as Namespaces
TypeScript modules use imports and exports under the chosen runtime/module system; type-only declarations disappear after compilation. Ruby require_relative loads a file and modules explicitly organize constants and methods. A filename creates no Ruby…
TypeScript1export {};2class TextTools{static shout(text:string):string{return text.toUpperCase();}}3console.log(TextTools.shout("elm"));Ruby1module TextTools2 def self.shout(text)3 text.upcase4 end5end6puts TextTools.shout("elm")Composing Objects
TypeScript and Ruby classes can retain collaborator references without cloning them or transferring exclusive ownership. TypeScript interfaces specify structural compile-time contracts, while Ruby duck typing calls compatible methods at runtime. Delegation…
TypeScript1export {};2interface Lens{label():string}3class WideLens implements Lens{label():string{return "wide";}}4class Camera{constructor(private lens:Lens){}label():string{return this.lens.label();}}5console.log(new Camera(new WideLens()).label());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 TypeScript Programs
2 lessonsFrequently asked questions
Who is Ruby for TypeScript Developers for?
For people who already write TypeScript and want to learn Ruby. Each lesson starts from TypeScript 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 TypeScript basics: variables, conditions, loops, functions and collections.
How many lessons does Ruby for TypeScript Developers have?
Ruby for TypeScript Developers contains 48 interactive lessons you can complete at your own pace.
What does Ruby for TypeScript 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 TypeScript Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.