Skip to main content

Class 3: Ruby, continued

Held: Friday, 27 January 2017

We continue to investigate some issues in Ruby.



  • A brief introduction to Ruby
  • Some exercises
  • Interesting characteristics of Ruby
  • Q&A


News / Etc.

  • I realize that there have been some problems getting up and running with Ruby and Cloud 9 and everything. That’s to be expected.
  • Reflections should generally be submitted by 9pm on Sunday night so that I can read them before class.
  • Friday PSA

Upcoming work

  • Read and do Hartl, chapter 1.

Good things to do

  • Various dance activities.
  • CS table, Tuesday: Planning for the semester.
  • CS extras, Thursday: LaTeX.

A brief introduction to Ruby

  • Modern programming language.
  • “One” designer.
  • Imperative, functional, and OOP characteristics.
  • Good at “Get the job done quickly.”
  • Very dynamic.
  • Very popular.
  • Everything (more or less) is an object.
  • Includes anonymous functions, although with a different syntax than we might expect.
  • Disadvantage: Too many ways to express the same concept.

      if TEST consequent
      consequent if TEST
      if TEST
      unless not TEST
      consequent unless not TEST

Some Ruby exercises

We will explore some of the examples from today’s assignment to see the different ways in which students approached problems.

Write sums_to_n?(vals,val) that returns true if any two distinct values from vals (a list of values) sums to val.

Write multiple_of_4?(bitstring) that takes a string of 0’s and 1’s (representing an unsigned integer) as input and returns true if the string represents an integer divisible by four.

Write starts_with_consonant?(str) that determines if a string starts with a consonant.

Additional characteristics of Ruby

What did you see as important characteristics of Ruby?