mirror of
https://github.com/hi-language/hi-language.github.io.git
synced 2026-01-14 16:48:37 +00:00
Refactor: Simplify counter example, remove explicit return
This commit is contained in:
11
index.html
11
index.html
@@ -49,7 +49,7 @@
|
|||||||
.markdown-body code {
|
.markdown-body code {
|
||||||
font-family: 'JetBrains Mono', monospace;
|
font-family: 'JetBrains Mono', monospace;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
font-variant-ligatures: none; /* Your requested change, Master */
|
font-variant-ligatures: none;
|
||||||
}
|
}
|
||||||
:not(pre) > code {
|
:not(pre) > code {
|
||||||
font-size: 85%;
|
font-size: 85%;
|
||||||
@@ -137,15 +137,12 @@ counter: {
|
|||||||
|
|
||||||
inc: {
|
inc: {
|
||||||
value = value + 1 // Mutates parent's private state
|
value = value + 1 // Mutates parent's private state
|
||||||
}
|
_("The count is now: " + value)
|
||||||
|
|
||||||
get: {
|
|
||||||
^ value // The last expression is returned, use ^ to be explicit
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
counter.inc()
|
counter.inc() // Prints "The count is now: 1"
|
||||||
_(counter.get()) // Prints 1
|
counter.inc() // Prints "The count is now: 2"
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
### Blocks with Parameters
|
### Blocks with Parameters
|
||||||
|
|||||||
Reference in New Issue
Block a user