Comments
Comments are useful for denoting useful information inside source code. Quby uses C-style comments, which are also used in JavaScript, and there are three types:
Single Line
These comments work from where they start, up to the end of the line. They are started using two forward slash characters.
// this is a single line comment
// and example of comments
def drawRect(
// where to draw
x, y,
// the size
width, height,
// lets centre it
true
)
a = 5 // comments can appear after a statementMulti-Line Comments
Using '/*' and '*/' to start and end these comments, they will span multiple lines. You can also insert them into the middle of a statement.
/* This is a
* multi-line
* comment
*/
num = /* and can appear inside a statement */ 0They are useful as an alternative to writing multiple-single line comments.
Documentation Comments
If you start a multi-line comment with two stars, '/**', then it will be a documentation comment.
/**
* A simple Sprite class,
* to help show off the useful-ness
* of documentation comments.
*/
class Sprite
/**
* Increments the location by the values given.
*/
def move( x, y )
// do something
end
endThey are useful for being a more formal version of a multi-line comment, and are typically used above variables, methods and classes.
Counted Comments
Comments in Quby are 'counted' or 'nested'. This means you can place a comment inside of a comment. For example:
/*
* /*
* A nested comment
* */
*
*/
/**
*
* /**
* another nested comment
*
* /**
* with more nesting
* */
* */
*/This is useful as it allows you to comment out large blocks of code, without having to worry about any comments getting caught inside it, and messing this up.
