-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathComments.tex
22 lines (14 loc) · 1.53 KB
/
Comments.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
\section{Comments}
All text in your code that shows in red color is a \emph{comment}. If you are new to programming languages, comments are a very useful way to document your code, both for yourself and for others who may have to read it later. Any line that starts with a double slash is a comment. You can write comments right after a valid line of code; the comment part will be ignored when you evaluate. In SC we use a semicolon to indicate the end of a valid statement.
\begin{lstlisting}[style=SuperCollider-IDE, basicstyle=\scttfamily\footnotesize]
2 + 5 + 10 - 5; // just doing some math
rrand(10, 20); // generate a random number between 10 and 20
\end{lstlisting}
You can evaluate a line even if your cursor is in the middle of the comment after that line. The comment part is ignored. The next two paragraphs will be written as ``comments'' just for the sake of the example.
\begin{lstlisting}[style=SuperCollider-IDE, basicstyle=\scttfamily\footnotesize]
// You can quickly comment out one line of code using the shortcut [ctrl+/].
"Some SC code here...".postln;
2 + 2;
// If you write a really long comment, your text may break into what looks like a new line that does *not* start with a double slash. That still counts as a single line of comment.
/* Use "slash + asterisk" to start a longer comment with several lines. Close the big comment chunk with "asterisk + slash." The shortcut mentioned above also works for big chunks: simply select the lines of code you want to comment out, and hit [ctrl+/]. Same to un-comment. */
\end{lstlisting}