Lessons

Crystal · Medium

Crystal · Medium. Ten lessons. Open-book quizzes. Lesson 1 free.

10 lessons · The Host · Lesson 1 free

Pass all ten lessons for the certificate. Sample · Claim

  1. Structs and value semantics

    Lesson 1 · On the house

    Structs and value semantics

    Know when a struct beats a class: structs copy on assignment and argument passing, compare by fields, and live on the stack.

  2. Modules: include, extend and namespaces

    Lesson 2

    Modules: include, extend and namespaces

    Share behaviour with include, add class-level methods with extend, group code under a namespace, and build utility modules with extend self.

  3. Abstract classes and overloads

    Lesson 3

    Abstract classes and overloads

    Define an abstract base with abstract defs, keep shared logic in the parent, and overload methods by type restriction so the compiler picks the right one.

  4. Union types and flow typing

    Lesson 4

    Union types and flow typing

    Work with values that can be more than one type: narrow with is_a?, case and if var, cast with as and as?, and copy instance variables before narrowing.

  5. Procs, closures and captured blocks

    Lesson 5

    Procs, closures and captured blocks

    Create procs with ->, capture variables in closures, turn methods into procs, store blocks with &block, and pass procs where a block is expected.

  6. Splats, named arguments and tuples

    Lesson 6

    Splats, named arguments and tuples

    Accept any number of arguments with *args, options with **opts, force named arguments after *, use external names, and destructure tuples.

  7. Exceptions in depth

    Lesson 7

    Exceptions in depth

    Build an exception hierarchy, rescue by type in order, use else and ensure, rescue in a method body, use begin as an expression, and retry with a loop.

  8. Testing with Spec

    Lesson 8

    Testing with Spec

    Write tests with the built-in Spec library: describe and it blocks, should eq, be_true, be_nil, contain, be_close and expect_raises, run by crystal spec.

  9. IO, IO::Memory and Process

    Lesson 9

    IO, IO::Memory and Process

    Write to any IO with << and puts, read lines from IO::Memory, pass IO into methods for testable output, run commands with Process.run, and read ENV.

  10. Concurrency patterns: select, timeouts and Mutex

    Lesson 10

    Concurrency patterns: select, timeouts and Mutex

    Wait on several channels with select, add timeouts and non-blocking checks, protect shared state with Mutex, and run a worker pool.

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.

All lessons