Ruby Essentials
The behaviour underneath the friendly syntax. Only nil and false are falsy, symbols are not strings, string literals are mutable, and a method returns its last expression whether or not you meant it to.
Who it is for
Knows the syntax, not yet the behaviour.
Start here. It assumes you can read the language and nothing else.
You will get the most out of it if you have written Ruby recently enough to read it without effort, and have been surprised by it at least once.
How long it takes
90 graded questions at roughly 45 seconds each is about 68 minutes of answering in total.
At the default five questions a day, and because the session mixes in your other courses, expect around 18 days — call it 3 weeks — to see everything once, plus a few weeks of thinning reviews after that before it is all mastered.
A question is mastered on the third correct answer, once the gap between reviews has grown past a week — so a course cannot be finished in a weekend however long you sit with it.
Question mix
- 60 multiple choice
- 10 concept cards
- 10 predict the output
- 10 put it in order
- 10 matching questions
Syllabus
What you will be asked about
-
01
Everything Is an Object
Explain why nil, integers and classes all answer method calls, and what that buys you.
-
02
Truthiness
Decide what Ruby treats as true in a condition, and why 0 and the empty string are not exceptions.
-
03
Symbols and Strings
Choose between a Symbol and a String, and predict where the two are not interchangeable.
-
04
String Mutability
Predict which string operations change an existing object and which build a new one.
-
05
Calls Without Parentheses
Read a paren-less call correctly, and tell a local variable from a method of the same name.
-
06
Implicit Return
Work out what a method returns when there is no return statement.
-
07
puts, print, p and inspect
Choose the right output method and predict exactly what each one writes.
-
08
nil and Safe Navigation
Handle a nil value without a NoMethodError, and know what &. actually guards against.
-
09
Ranges
Build the range you meant, and predict what it contains at each end.
-
10
Blocks, the Basics
Pass a block to a method, use its value, and know when yield will raise.
A question from this course
Everything Is an Object
What does this print?
p nil.class
Show the answer
B NilClass
nil is not an absence of an object; it is nil, the single instance of NilClass. You may have expected nil or an error because in many languages null has no type at all. In Ruby it has a class, a to_s and a to_a, which is why calling methods on it so often quietly succeeds.
The rest of the track
Ruby at every depth
Ruby Core
Where Ruby trips people who use it daily. Blocks against procs against lambdas, the ancestor chain and method lookup, the three kinds of equality, and what happens when two names point at the same object.
Ruby Data & Collections
Array, Hash, Set and Enumerable in earnest. Bang methods that return nil, Hash defaults that share one object between every key, fetch against [], grouping and tally, and lazy enumerators that are not always cheaper.
Ruby Errors & Edge Cases
Exceptions and their edges. Rescue ordering, StandardError against Exception, what an ensure does to a return value, retry, and the difference between catch/throw and raising at all.
Ruby Standard Library
The library people reimplement by hand: Struct and Data, Set, the Comparable and Enumerable mixins, Forwardable, JSON, Digest and BigDecimal. Ten places where a built-in already does the job, and one behaviour in each that is not what you assumed.
Ruby Idioms & Pitfalls
The Ruby people write out of habit that is wrong or merely un-Ruby: for loops that leak their variable, and versus &&, unless with an else, ||= on a false value, map followed by compact, and rescuing Exception. Ten habits, and the behaviour that punishes each one.
Ruby Advanced
The metaprogramming that still catches experienced Rubyists: singleton classes, method_missing, refinements, prepend, and the two searches behind constant lookup. Every snippet is one you could be handed in a code review.
Ruby Performance
What actually costs in MRI: object allocation, frozen and deduplicated strings, symbol keys, array and string growth, lazy enumerators, and the generational collector. Every claim is one you can measure with GC.stat rather than guess at.
Ruby Testing
What a test actually asserts, and where that claim is weaker than it looks. Argument order and failure messages, the three kinds of equality, exceptions, isolation between examples, and the difference between a failure and an error.
Ruby Interview Questions
The Ruby questions interviewers actually ask, and the answers that need a reason attached. Proc and lambda return semantics, the ancestor chain, mixins, duck typing, shared references, symbols, method_missing, memoisation and Enumerable built by hand.
Start Ruby Essentials
in tomorrow’s session.
Enrol and this course joins your daily five, mixed in with everything else you are studying — 90 questions spread over about 18 days rather than dropped on you at once.
Browse the catalogue