When You Teach Just Use `each`

There are a quite a few lessons that I have re-learned while teaching Ruby to this inaugural class of gSchool students.

I have taught programming to a wide array of individuals during my time as a Ruby developer. The breadth of these interactions pales in comparison to the time I’ve spent with the gSchool students. The amazing part of being an instructor in this program is my ability to receive feedback and see what I have wrought.

Early on in the program, while reviewing the daily warm up activities, I made a mistake.

  # ... rest of the function
  numbers = []
  word.each_char do |letter|
    numbers << letter.to_i
  return numbers

The mistake I made was not in my initial solution; it was in the steps that followed.

First I employed map method:

  # ... rest of the function
  word.each_char.map { |letter| letter.to_i }

And then suggested Symbol#to_proc

  # ... rest of the function

You will not find a mistake in the code. The mistake I made was in my instruction to my audience.

This exercise took place during the early days of the program, so I should have curbed my rabid desire to refactor and stopped at my initial solution. Not because the students should never see any of these subsequent examples but because it was not the right time.

Refactoring is a demonstration of mastery, and mastery only comes after one has learned the basics.

My advice to those teaching others to code: remember your audience.

comments powered by Disqus

Upcoming Events

  • GoGaRuCo 2013

    GoGaRuCo 2013

    Mission Bay Conference Center

    September 20 & 21 - San Francisco, CA

  • RuPy 2013

    RuPy 2013

    October 11-14 - Budapest, Hungary

Contact Us

(202) 670-2852
(202) 280–1257
1510 Blake Street
Denver, CO 80202 U.S.A

Stay Connected

Get the scoop on upcoming classes.