Lessons
Crystal · Easy
Crystal · Easy. Ten lessons. Open-book quizzes. Lesson 1 free.
10 lessons · The Host · Lesson 1 free
Pass all ten lessons for the certificate. Sample · Claim

Lesson 1 · On the house
Generics: Holder(T), Stack(T) and forall
Write generic classes with a type parameter, let the compiler infer T from new, and write generic methods with forall.

Lesson 2
Enums and flags
Declare enums with named values, read .value, compare with predicates like red?, parse strings, add methods, and combine @[Flags] members.

Lesson 3
Enumerable in depth
Use each_with_index, group_by, tally, partition, sort_by, min_by, each_slice, zip and sum with a block on real data.

Lesson 4
Strings and String.build
Split, strip, search and replace strings, pad columns, index by character, and build big strings efficiently with String.build.

Lesson 5
Regular expressions
Match text with /regex/, read captures from match and $~, use named groups, scan for every match, and rewrite with gsub and a block.

Lesson 6
Operator overloading and Comparable
Define +, -, * and [] as methods, implement <=> and include Comparable to get <, >, clamp and sort, and define == for value equality.

Lesson 7
Your own collections: Enumerable and Iterator
Include Enumerable(T) and define each to get map, select and sum; implement Iterator(T) with next and stop for lazy, chainable sequences.

Lesson 8
Macros and record
Use record for value types, write a macro with {{ }} interpolation and {% for %} loops, and see that macros expand to code at compile time.

Lesson 9
Fibers and channels
Run concurrent work with spawn, pass values through Channel(T) with send and receive, use buffered channels, and wait for workers with WaitGroup.

Lesson 10
Files and JSON
Write and read files, iterate lines, check paths, parse JSON with JSON.parse and as_i, and map JSON to classes with JSON::Serializable.
Sample certificate
Certificate of completion
Sign in to claim your certificate of completion.
Certificate
Finish all ten lessons, then sign in
Pass every lesson on this device (quizzes and checks). Then sign in or create an account to type your name and download the JPG.