Screen Too Small

This course material requires a larger screen to properly display the terminal and editor interfaces.

Please use a tablet, laptop, or desktop computer for the best learning experience.

You can continue browsing, but the experience will be significantly limited.

Vim Dojo challenge #22

🧹 chore.rb Cleanup

Your kid is learning Ruby and made a great start — now help them level up! Refactor this seasonal chore class so it calls real methods and reads cleanly.

challenge.txt :set list

Start

 1class Chore
 2  def initialize(stuff)
 3  @stuff = stuff
 4  end
 5  def do_all
 6for thing in @stuff
 7do
 8puts thing
 9end
10end
11  def rake_leaves
12puts "Raking leaves..."
13end
14 def make_pumpkin_spice_latte
15puts "Brewing pumpkin spice latte..."
16end
17end

Goal

 1class Chore
 2  def initialize(chores)
 3    @chores = chores
 4  end
 5
 6  def do_all
 7    for chore in @chores do
 8      send(chore)
 9    end
10  end
11
12  def rake_leaves
13    puts "Raking leaves..."
14  end
15
16  def make_pumpkin_spice_latte
17    puts "Brewing pumpkin spice latte..."
18  end
19end

Members only

Hold on, cowboy

You gotta sign in to take on challenges. New ones drop every week — they're fun, and insightful.