Learn Ruby
Learn Ruby, the friendly object-oriented language behind Ruby on Rails. Work with strings, numbers and methods, control flow and loops, arrays and hashes, blocks, procs and lambdas, and write your own classes and modules.
- Beginner level
- 10 modules
- 49 lessons
- 252 tasks and questions
Syllabus
01Introduction to RubyPrint output, use Ruby's basic data types, do math, call methods on strings, and write comments.6 lessons
02Control FlowMake decisions with if, elsif, else and unless, compare values, combine conditions with boolean operators, and transform text with conditional logic.5 lessons
03Loops and IteratorsRepeat code with while, until and for loops, control loops with break and next, and use Ruby's iterators each and times.5 lessons
04Arrays and HashesStore ordered lists in arrays and key-value pairs in hashes, access and change their contents, and iterate over both.5 lessons
05Methods, Blocks and SortingDefine your own methods with parameters, defaults, splats and return values, pass blocks to methods, and sort collections with sort, the spaceship operator and sort_by.5 lessons
06Hashes and SymbolsMeet symbols, the modern hash syntax, converting between strings and symbols, and the hash methods you'll use every day.5 lessons
07Refactoring the Ruby WayWrite shorter, clearer Ruby with one-line conditionals, the ternary operator, conditional assignment, implicit returns and idiomatic iterators.4 lessons
08Blocks, Procs and LambdasLearn how Ruby packages code to pass around: blocks and yield, Proc objects, symbol-to-proc shortcuts and lambdas, and how they differ.4 lessons
09Object-Oriented Programming, Part IDefine classes with initialize and instance variables, add methods, understand variable scope, and reuse code through inheritance and super.5 lessons
10Object-Oriented Programming, Part IIControl access with public and private methods, generate getters and setters with attr_reader, attr_writer and attr_accessor, and share behavior with modules and mixins.5 lessons