Ruby Basics
| Feature | Example |
| Variables | name = "Ruby" (no type declaration) |
| String interpolation | "Hello, #{name}" |
| Symbols | :symbol — immutable, memory-efficient strings |
| Arrays | arr = [1, 2, 3]; arr << 4 |
| Hashes | hash = {key: "value", foo: "bar"} |
Blocks & Iterators
| Pattern | Example |
| Each | [1,2,3].each { |n| puts n } |
| Map | [1,2,3].map { |n| n * 2 } → [2,4,6] |
| Select | [1,2,3,4].select { |n| n.even? } → [2,4] |
| Do...end | 3.times do |i| puts i end |
Classes & Modules
| Feature | Example |
| Class | class User; attr_accessor :name; def initialize(name); @name = name; end; end |
| Inheritance | class Admin < User; end |
| Module (mixin) | module Loggable; def log(msg); puts msg; end; end |
Popular Gems
| Gem | Purpose |
| Rails | Full-stack web framework |
| RSpec | Testing framework |
| Devise | Authentication for Rails |
| Sidekiq | Background job processing |
Pro Tip: Ruby's principle of least surprise: code should behave the way you expect. Methods ending in ? return booleans (empty?), methods ending in ! modify the receiver (sort!). This convention makes Ruby code read like English.