1
0
mirror of https://github.com/onkelbeh/cheatsheets.git synced 2026-01-12 22:12:04 +01:00

Update _docs/writing-guidelines.md

This commit is contained in:
Rico Sta. Cruz 2025-11-02 00:04:27 +11:00
parent 793a2627a7
commit 4ed38842a3
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A

View File

@ -92,3 +92,55 @@ H3 content length:
Trigger reflexes without writing any javascript with the `data-reflex` attribute.
````
- When showing reference information, use tables for quick scanning. Example:
````markdown
### Primitives
| Sample | Type |
| --- | --- |
| `nil` | Nil/null |
| `true` _/_ `false` | Boolean |
| --- | --- |
| `23` | Integer |
| `3.14` | Float |
| --- | --- |
| `"hello"` | Binary string |
| `:hello` | Atom |
These are the basic data types in Elixir.
````
- Use inline comments to explain results, equivalents, or provide context. Example:
````markdown
### Pattern matching
```elixir
user = %{name: "Tom", age: 23}
%{name: username} = user # → username = "Tom"
```
### Piping
```elixir
source
|> transform(:hello) # Step 1: transform the data
|> print() # Step 2: output the result
```
```elixir
# Same as:
print(transform(source, :hello))
```
### Type conversions
```elixir
Integer.parse("34") # → {34, ""}
Float.parse("34.1") # → {34.1, ""}
```
````
```