Skip to content
academia.sh

Unit 02 of 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.

Published Updated

Lessons

  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. 6 min read
  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. 10 min read
  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. 7 min read
  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. 13 min read
  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. 7 min read
  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. 15 min read

Start typing to search.

↑↓ ↵ Esc navigate · open · close