Learn Crystal through test-driven exercises. Fix failing tests to achieve enlightenment.
Crystal Koans is an interactive learning tool inspired by Ruby Koans. Walk the path of the koans, fixing one failing test at a time, and gain hands-on proficiency in Crystal.
- Crystal 1.17.1 or higher (Install Crystal)
# Clone the repository
git clone https://github.com/jkthorne/koans.git
cd koans
# Start your journey
crystal run src/path_to_enlightenment.crRun the koans in order, stopping at the first failure:
crystal run src/path_to_enlightenment.crThe path will guide you through each koan. When a test fails:
- Read the failure message
- Open the indicated file
- Replace
FILL_ME_IN(or other placeholder) with the correct value - Run again and repeat
Run all tests at once:
crystal spec spec/koans/Focus on a specific topic:
crystal spec spec/koans/01_about_asserts_spec.crStart fresh by clearing cached progress:
crystal run src/path_to_enlightenment.cr -- --resetThe koans cover 30 topics, progressing from basics to Crystal-specific features:
Fundamentals
- Asserts, Nil, Numbers, Strings, Symbols
- Arrays, Hashes, Control Statements
- True and False, Methods, Blocks
- Procs and Lambdas, Classes, Inheritance, Modules
Intermediate
- Scope, Self, Constants
- Method Visibility, Exceptions
Crystal-Specific
- Union Types, Type Inference
- Generics, Enums, Macros
- Concurrency (Fibers & Channels)
- Regular Expressions, Open Classes
- Structs, Tuples
Replace these with the correct values:
__- Generic placeholder (returns "FILL ME IN")__n__- Numeric placeholder (returns 999999999)__f__- Float placeholder (returns 999999999.999)__bool__- Boolean placeholder (returns false)__char__- Character placeholder__array__- Array placeholder__hash__- Hash placeholder
- Fork it (https://github.com/your-github-user/crystal-koans/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
MIT License - see LICENSE
Inspired by Ruby Koans by EdgeCase.