AnyCompiler

Closing Thoughts

This course started with a claim: Ruby isn't just Perl or Python with different syntax. By now you've seen the actual evidence. Blocks ({ } / do...end, plus yield) are Ruby's own mechanism for passing code into a method call — not a lambda literal like every other language on this site uses. Symbols (:name) are a genuinely distinct, identity-stable type with no real equivalent anywhere else here. Methods return their last expression's value automatically, with no return keyword required. And module/include gives a class composable behavior from multiple independent sources at once, a model neither Java/C#/Kotlin's interfaces nor Rust's traits quite match.

All of it rests on the single idea from lesson 5: there is no value in Ruby — not a number, not nil, not true — that sits outside the object system. Once that clicks, blocks, mixins, and symbols stop looking like quirks and start looking like a coherent design: a language built, top to bottom, around objects sending messages to each other.

module Summarizable
  def summary
    ":#{name} -> #{role}"
  end
end

class Teammate
  include Summarizable
  attr_reader :name, :role
  def initialize(name, role)
    @name = name
    @role = role
  end
end

team = [Teammate.new("Ada", :engineer), Teammate.new("Grace", :lead)]
team.each { |t| puts t.summary }
Output
:Ada -> engineer
:Grace -> lead

One last example pulling it all together: a mixin (Summarizable) supplying shared behavior, attr_reader generating clean accessors, symbols (:engineer, :lead) as lightweight role identifiers, and .each with a block driving the iteration — five lessons' worth of ideas in nine lines. That's Ruby. Thanks for working through this course — more lessons, including localized versions, are planned.

Practice exercise

Read a line from stdin into name using gets.chomp, then print "Goodbye, " followed by name, followed by "! Keep exploring Ruby."

← ExceptionsMore lessons coming soon