January 2019
Intermediate to advanced
246 pages
5h 23m
English
You do document your code, don’t you? Crystal makes that easy: it allows for easy docs in Markdown format. It has no special doc syntax apart from #, so all your comments are documentation. First, read through the guidelines.[43] Now let’s add some doc comments to your mineral project (you did create the exercise, didn’t you?). Here’s an example:
| | require "./mineral/*" |
| | |
| | module Mineral |
| | puts "app mineral is started!" |
| | module Hardness |
| | def data |
| | mohs = {"talc" => 1, "gold" => 2.5, "calcite" => 3, |
| | "apatite" => 5, "corundum" => 9} |
| | end |
| | |
| | def hardness |
| | data[self.name] |
| | end |
| | end |
| | |
| | # Every Mineral has **hardness** (see the `Hardness` module). ... |
Read now
Unlock full access