Comments

Automatic Comments

Figures allows you to include words with your calculations to give them context. Any word that you haven't assigned a value is automatically marked as a comment.

lunch bill = $4 for a tuna sandwich + $1 for chips
total paid = lunch bill + 8% sales tax + $1 tip
$5
$6.40

NOTE

Automatic comments can be turned off by going to Preferences > Editing > Automation

Line Comments

You can quickly ignore a line of calculations by prefacing it with //.

total value = 42
// total value += 1
total value
42

42

A line comment can begin anywhere on the line, and it will apply to the rest of the line. This is a convenient way to add a note to a calculation.

trip costs = $80 for gas
trip costs += $30 for meals + $120 for lodging  // Thursday
trip costs += $42 for meals + $120 for lodging  // Friday
$80
$230
$392

Block Comments

If you want a larger block of comments, surround your text with the block comment delimiters #/ and /#. Block comments work across multiple lines and make a convenient way to write a longer description of your calculation.

#/
Volume of the new pool

The pool will be shallower on one end,
so this calculation is going to be a little high.
/#
pool volume = 12m long × 5m wide × 2m deep







Block comments can also be intermixed on a single line. In the example below, note that the variable's name is just p.

circumference = 32 meters
diameter = 10.2 meters
p #/ an approximation of pi /# = circumference / diameter
p + 2
32 m
10.2 m
3.14
5.14

Documentation Comments

Figures has a Quick Help feature that lets you see a description of variables and functions. These descriptions are a convenient way for you to learn how to use built-in values. To try this feature, type a built-in name like pi and Option-click on the name. This will display a pop-up window with information about the name you clicked on.

Quick help

NOTE

You can select which key brings up the Quick Help pop-up by going to Preferences > Editing > Display

You can provide descriptions of your own values via documentation comments. These will be shown in Quick Help just like built-in values. A documentation comment works similar to a line comment, but it's prefaced by three slashes /// and placed on the line above the value.

/// The sales tax rate in my area
tax rate = 11%

11%
Custom quick help

The first comment line will always be the summary of the value. Following a blank comment line, any additional comment lines will be added to the discussion area of Quick Help.

/// The sales tax rate in my area
///
/// This tax rate is only valid
/// within the county borders
tax rate = 11%




11%
Quick help with discussion

Documentation comments can also use Markdown to style your descriptions. Most common Markdown formatting is supported.

/// The speed that light travels in a vacuum
///
/// A __universal__ constant.
/// Other values include:
/// - 300,000 km/s
/// - 186,000 mi/s
///
/// Denoted with the symbol `c`.
/// ```
/// distance = light speed × 3,600
/// ```
light speed = 3 × 10 m/s











300 million m/s
Quick help with Markdown

If the documentation comment is associated with a function, there are a couple additional formatting options available. First, you can provide descriptions of the parameters with a list.

/// Calculates the monthly payment of a mortgage
///
/// - Parameters:
///   - total: The total amount of the mortgage
///   - down payment: The amount paid up front
///   - months: The number of months the mortage will be paid
fun mortgage(total, down payment, months) {
    
}
mortgage(total: $200k, down payment: $40k, months: 36)










Quick help with parameters

You can also specify the parameters individually.

/// Calculates the monthly payment of a mortgage
///
/// - Parameter total: The total amount of the mortgage
/// - Parameter down payment: The amount paid up front
/// - Parameter months: The number of months the mortage will be paid
fun mortgage(total, down payment, months) {
    
}
mortgage(total: $200k, down payment: $40k, months: 36)









Finally, you can specify what kind of value is returned from the function.

/// Calculates the monthly payment of a mortgage
///
/// - Returns: The monthly payment for the mortgage, in dollars
fun mortgage(total: total cost,
             down payment: amount down,
             months: number of months) {
    
}
mortgage(total: $200k, down payment: $40k, months: 36)









Didn't find what you were looking for?

Contact Us