Code Block
Display the text as a block of code.
Works with:
✓ Playgrounds
✓ Symbol documentation
Syntax
Start each line of a code block indented at least four spaces or one tab from the indent level for the current delimiter. For information on indent level, see Quick Help Sections. There are empty lines above and below the code block.
…
code line
…
…
Alternate syntax for symbol documentation
Enter four backquotes (`
) on a line above and below the lines for the code block. The four backquotes start at the indent level for the current delimiter. For information on indent level, see Quick Help Sections.
````
code line
…
````
Playground Example
Lines 3-5 in the markup below result in the code block shown in the screenshot.
/*:
A loop to print each character on a seperate line
for character in "Aesop" {
println(character)
}
*/
Quick Help Example
Lines 5-7 in each of the comment blocks below result in the code block shown in screenshot.
/**
An example of using a *code block*
A loop to print each character on a seperate line
for character in "Aesop" {
print(character)}
}
*/
Alternate syntax
/**
An example of using a *code block*
A loop to print each character on a seperate line
````
for character in "Aesop" {
print(character)}
}
````
*/
Copyright © 2018 Apple Inc. All rights reserved. Terms of Use | Privacy Policy | Updated: 2017-06-05