Learn Ruby – all lessons
16 lessons from beginner to advanced, building on each other and with code examples.
Hello World, puts & irb
Your first Ruby program and the idea "everything is an object".
Variables, Types & Strings
Local variables, numbers, strings, interpolation and constants.
Conditions: if, unless, case
Deciding with if/elsif/else, the modifier form and the powerful case/when.
Loops and Iterators
times, each, upto, step, while, until and loop.
Defining Methods
def, default values, keyword arguments, splat and the implicit return value.
Arrays and Hashes
The two most important collections and their most common pitfalls.
Blocks, Procs & Lambdas
The heart of Ruby: passing code as an argument, yield and closures.
Symbols & Strings in Detail
Symbols vs. strings, important string methods, heredocs and frozen strings.
Enumerable: map, select, reduce & Co.
Processing data without loops – with the methods that arrays, hashes and ranges share.
Classes & Objects
Attributes, constructor, inheritance, visibility and comparisons.
Modules, Mixins & Comparable
include, extend, prepend, namespaces as well as Enumerable and Comparable for your own classes.
Struct, Data & Pattern Matching
Quick data classes with Struct, immutable ones with Data and pattern matching with case/in.
Errors, Files & JSON
begin/rescue/ensure, custom error classes, retry, the File API and JSON.
Gems, Bundler & Tests
Installing libraries, managing dependencies per project and testing code.
Metaprogramming & DSLs
method_missing, define_method, open classes, refinements and self-built DSLs.
Ruby on Rails: the Basic Idea
MVC, convention over configuration, ActiveRecord and the typical flow of a Rails app.