Ruby Tutorial
Learn Ruby step by step through 79 structured lessons. The course starts with essential concepts and progresses toward practical, advanced topics, with explanations, syntax, examples, common mistakes and exercises you can try yourself.
- Level: Beginner to advanced
- Format: 79 free, self-paced lessons
- Best for: Students, career changers and developers refreshing their skills
What You Will Learn
This learning path covers the following areas in curriculum order:
- Ruby Fundamentals
- Ruby Basics
- Control Flow
- Arrays and Hashes
- Methods
- Blocks, Procs, and Lambdas
- Enumerable and Iteration
- Classes and Objects
- Modules and Mixins
- Object-Oriented Design
- Error Handling
- Strings and Regular Expressions
- Pattern Matching
- Files, Gems, and Testing
- Ruby Best Practices
Who This Course Is For
This tutorial is suitable for complete beginners as well as learners who already know some programming and want a structured reference. Start from the first lesson if the subject is new to you. Experienced learners can use the curriculum below to jump directly to a specific concept.
How to Use This Tutorial
- Read each lesson in curriculum order and run every example yourself.
- Change the examples to test your understanding instead of only copying them.
- Complete the exercises and review the common-mistake sections before moving on.
- Bookmark this course page so you can return to the complete lesson index.
Course Contents
Ruby Fundamentals
- Ruby Introduction
- Installing Ruby
- Ruby Get Started (Hello World)
- How Ruby Works: Interpreted and Object-Oriented
- Running Ruby Scripts and IRB
- Comments and Documentation
Ruby Basics
Control Flow
- if, elsif, and unless
- case Expressions
- Everything Is an Expression
- while and until Loops
- for Loops and Iterators
- Statement Modifiers
Arrays and Hashes
Methods
- Defining Methods
- Default and Keyword Arguments
- Variable-Length Arguments (splat)
- Implicit Return
- Endless Methods
- Method Naming Conventions (?, !)
Blocks, Procs, and Lambdas
- Blocks Explained
- yield and Block Arguments
- Procs
- Lambdas
- Procs vs Lambdas
- Passing Blocks as Arguments (&block)
Enumerable and Iteration
- The each Method
- map and select
- reduce and inject
- sort and sort_by
- Chaining Enumerable Methods
- Lazy Enumerators
Classes and Objects
- Classes in Ruby
- Instance Variables and attr_accessor
- The initialize Method
- Instance Methods and Class Methods
- Inheritance
- super
Modules and Mixins
- Modules Explained
- Mixins with include
- extend and Module Functions
- Namespacing with Modules
- Comparable and Enumerable Mixins
Object-Oriented Design
- Encapsulation and Access Control
- Duck Typing
- Method Missing and Dynamic Methods
- Operator Overloading
- Struct and Data Classes
Error Handling
- Exceptions in Ruby
- begin, rescue, ensure
- Raising Exceptions
- Custom Exception Classes
- retry and Exception Hierarchies
Strings and Regular Expressions
- String Methods
- Regular Expressions in Ruby
- Pattern Matching with match and scan
- gsub and String Substitution
- Formatting Strings (format, sprintf)
Pattern Matching
- Pattern Matching with case/in
- Array and Hash Patterns
- Find Patterns and Guards
- Deconstruct and Deconstruct_keys
Files, Gems, and Testing
- Reading and Writing Files
- Working with JSON
- RubyGems and Bundler
- Organizing Code with require
- Testing with Minitest
- Writing RSpec-Style Tests
Ruby Best Practices
Frequently Asked Questions
Is this Ruby tutorial free?
Yes. The lessons listed on this page are free to read and can be completed at your own pace.
Do I need previous experience?
No previous experience is required for the introductory lessons. Some advanced modules are easier if you first complete the fundamentals in this course.
How should I practise?
Type and run the examples, deliberately change their inputs, predict the result before execution and build a small project after completing each major section.
