Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Treehouse

Ruby Blocks Course (How To)

via Treehouse

Overview

In this course, you’ll learn all about blocks in Ruby. Blocks are a piece of syntax that you can use in Ruby to accomplish all kinds of amazing programming feats. Ruby programmers make constant use of blocks so they are an important piece of the language to learn.

What you'll learn

  • Ruby Blocks
  • Ruby Classes
  • Block Arguments
  • Yield

Syllabus

Ruby Blocks

In this stage, you'll learn how blocks work in Ruby. You'll learn what blocks are, different ways they can be called, and how to pass arguments to a block.

Chevron 8 steps
  • What Are Blocks?

    3:59

  • Practice Writing a Block

    1 objective

  • Write a Block Method

    4:42

  • Write a Block Method

    1 objective

  • Block Arguments

    6:09

  • Block Arguments

    1 objective

  • Calling Blocks

    5:37

  • Calling Blocks

    1 objective

Working With Blocks

It's important to learn how blocks work in the real world. In this stage, you'll explore how blocks work in some of Ruby's built in types. You'll also learn how to create your own classes that implement methods with blocks.

Chevron 8 steps
  • Blocks in the Wild: Strings and Integers

    4:58

  • Block Method Practice: Strings

    1 objective

  • Blocks in the Wild: Arrays and Hashes

    7:06

  • Block Method Practice: Arrays

    1 objective

  • Build a Simple Benchmarker

    6:31

  • Block Method Practice: Custom Classes

    2 objectives

  • Implementing Block Methods

    3:30

  • Implementing Block Methods

    1 objective

Blocks Practice

It's important to practice what you've learned! In this stage, we'll practice using blocks by writing a Monster class that makes heavy use of blocks, hashes, and more.

Chevron 8 steps
  • Build a Monster Class: Part 1

    2:56

  • Create a Class

    3 objectives

  • Build a Monster Class: Part 2

    5:42

  • Yielding

    1 objective

  • Build a Monster Class: Part 3

    1:50

  • Running Code Before Executing Blocks

    2 objectives

  • Build a Monster Class: Part 4

    2:49

  • Yielding Self

    1 objective

Reviews

Start your review of Ruby Blocks Course (How To)

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.