8000 Add comment examples · HowProgrammingWorks/Book@a965242 · GitHub
[go: up one dir, main page]

Skip to content

Commit a965242

Browse files
committed
Add comment examples
1 parent 2a47d6e commit a965242

File tree

4 files changed

+153
-1
lines changed

4 files changed

+153
-1
lines changed

content/cz/2-Basic.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
11
# 2. Základní pojmy
22

33
No translation
4+
5+
```js
6+
// Single-line comment
7+
```
8+
9+
```js
10+
/*
11+
Multi-line
12+
comments
13+
*/
14+
```
15+
16+
```py
17+
# Single-line comment
18+
```
19+
20+
```py
21+
"""
22+
Multi-line
23+
comments
24+
"""
25+
```
26+
27+
```sql
28+
select name from PERSON -- comments in sql
29+
```
30+
31+
```html
32+
<!-- commented block in xml and html -->
33+
```
34+
35+
```
36+
; Single-line comment in Assembler and LISP
37+
```

content/en/2-Basic.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,53 @@
11
# 2. Basic concepts
22

3-
No translation
3+
We need comments to temporarily prevent code block execution or compilation, to store structured annotation or metadata (interpreted by special tools), to hold `TODOs` or developer-readable explanations.
4+
5+
> A `comment` is character sequences in the code ignored by the compiler or the interpreter.
6+
7+
Comments in all `C`-family languages like `C++`, `JavaScript`, `Java`, `C#`, `Swift`, `Kotlin`, `Go`, etc. have the same syntax.
8+
9+
```js
10+
// Single-line comment
11+
```
12+
13+
```js
14+
/*
15+
Multi-line
16+
comments
17+
*/
18+
```
19+
20+
Do not hold obvious things in comments, do not repeat something what is clear from the code itself.
21+
22+
In bash (shell-scripts) and Python we use number sign (sharp or hash symbol) for commenting.
23+
24+
```py
25+
# Single-line comment
26+
```
27+
28+
Python uses multi-line strings as multi-line comments with triple-quote syntax. But remember that it is a string literal not assigned to a variable.
29+
30+
```py
31+
"""
32+
Multi-line
33+
comments
34+
"""
35+
```
36+
37+
SQL uses two dashes to start a single-line comment to the end of line.
38+
39+
```sql
40+
select name from PERSON -- comments in sql
41+
```
42+
43+
HTML comments have just multi-line syntax.
44+
45+
```html
46+
<!-- commented block in xml and html -->
47+
```
48+
49+
In Assembler and multiple LISP dialects we use semicolons (or multiple semicolons) for different types of comments.
50+
51+
```
52+
; Single-line comment in Assembler and LISP
53+
```

content/ru/2-Basic.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
11
# 2. Базовые концепты
22

33
No translation
4+
5+
```js
6+
// Single-line comment
7+
```
8+
9+
```js
10+
/*
11+
Multi-line
12+
comments
13+
*/
14+
```
15+
16+
```py
17+
# Single-line comment
18+
```
19+
20+
```py
21+
"""
22+
Multi-line
23+
comments
24+
"""
25+
```
26+
27+
```sql
28+
select name from PERSON -- comments in sql
29+
```
30+
31+
```html
32+
<!-- commented block in xml and html -->
33+
```
34+
35+
```
36+
; Single-line comment in Assembler and LISP
37+
```

content/uk/2-Basic.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
11
## 2. Базові концепти
22

33
No translation
4+
5+
```js
6+
// Single-line comment
7+
```
8+
9+
```js
10+
/*
11+
Multi-line
12+
comments
13+
*/
14+
```
15+
16+
```py
17+
# Single-line comment
18+
```
19+
20+
```py
21+
"""
22+
Multi-line
23+
comments
24+
"""
25+
```
26+
27+
```sql
28+
select name from PERSON -- comments in sql
29+
```
30+
31+
```html
32+
<!-- commented block in xml and html -->
33+
```
34+
35+
```
36+
; Single-line comment in Assembler and LISP
37+
```

0 commit comments

Comments
 (0)
0