Skip to content
academia.sh

Course Beginner

Ruby Fundamentals

Published Updated

By the end of this course

Start course

01

Language Basics

A design that puts readability first turning even operators into methods, primitive values being objects too, naming rules and scope sigils, conditions and loops that produce values, methods with implicit return, and symbols and strings being two separate representations.

  1. 01 The Design Philosophy of Ruby In Ruby, 5 + 3, x = 5, the map of an array, and 5.between?(1, 10) are written the same way, yet the code that produces each result lives in four different places. This lesson measures those four responders with twelve observations and shows that a design that puts readability first turns even operators into methods.
  2. 02 An Intuition for the Object Model Numbers, nil, and true are objects too; in 5 + 3 the receiver is 5 and the responder is Integer; classes are objects themselves, and another class answers the messages sent to them.
  3. 03 Variables and Constants In Ruby, assignment is syntax rather than a message; local variables, instance variables, global variables, and constants are told apart by the sigil on the name; the limits measured with defined?.
  4. 04 Control Flow The case expression sends the === message to each when branch, while if and while are syntax that sends no message; statement modifiers and the value of if; the responder of case is the class of the branch object.
  5. 05 Methods Receiverless calls live in the Kernel module; method definitions with default values, variadic arguments, and keyword arguments; implicit return; a top-level def is written into Object and stays private.
  6. 06 Symbols and Strings A string turning into a symbol and the identity difference between the two representations; string literals frozen by a magic comment, and the comment taking effect per file; the magic comment not changing the responder.

02

Collections and Blocks

Arrays and hashes, blocks that pass behaviour into a method, Enumerable as a shared iteration interface, the difference between a proc and a lambda, catching and retrying exceptions, and text processing flows with files.

  1. 01 Arrays and Hashes Ruby's two basic collections, the array and the hash, are measured for which methods they answer themselves, which a shared module answers, and how a block decides the value of a missing key.
  2. 02 Blocks The same map message is measured giving two different results with two different blocks, a method is shown calling its block with yield, and the block is shown deciding the result without changing the class's return rule.
  3. 03 The `Enumerable` Module The iteration methods an array does not define itself are measured as coming from the Enumerable module, your own class is given the same ability with a single each, and the module is shown not to take over every job.
  4. 04 Procs and Lambdas For procs and lambdas, the two ways of turning a block into an object, a class is measured answering the call message, and the difference is shown to lie in argument checking and in the lambda? state.
  5. 05 Exceptions The rescue, ensure and retry constructs are measured as the language's own syntax, raise as a message, and the match in a rescue branch as being made with a message to a class.
  6. 06 Files and Input/Output In a File.open call, the block decides the result and the method decides that the file is closed; even when the block raises an exception, the file closes. The lesson also gives the closing table of the course's twelve observations.

Final exam

Ruby Fundamentals — Final Exam

In preparation

This course's question bank is not complete yet. The exam opens here automatically once enough questions are added.

Start typing to search.

↑↓ ↵ Esc navigate · open · close