1

Is the following correct use of a code block (the curly braces icon) in a Stack Overflow question?

def __init__(self,rect_len,rect_wid,stylus_in):
        self.len = rect_len
        self.wid = rect_wid
        self.stylus = stylus_in

When should I use a block quote (see following)?

Some block quote text

2
  • 3
    What curly braces ({})?
    – Thom A
    Dec 25, 2022 at 13:10
  • 2
    @Larnu the "curly braces" is the icon on the old (current) Stack Editor's toolbar.
    – Andrew T.
    Dec 25, 2022 at 13:12

1 Answer 1

6

A code block is for when you have code; hence why it's called a code block. A quote block is for when you are quoting something; that might be an article, documentation, a quote/comment, book, or even an error. If that quote constrains code then the code inside the quote block should also be in a code block.

A very rudimentary example would be for a code block:

SELECT *
FROM dbo.YourTable;

As for a quote, you might use it in the following context:

The documentation gives the following example for the COALESCE function:

A. Running a simple example

The following example shows how COALESCE selects the data from the first column that has a nonnull value. This example uses the AdventureWorks2019 database.

SELECT Name, Class, Color, ProductNumber,  
COALESCE(Class, Color, ProductNumber) AS FirstNotNull  
FROM Production.Product;

Some things that aren't code may also, however, be better in a code block. For example if you posting part of a stack trace from an application that is erroring, these often are better put in a code block, due to the fact that they formatted better™, as they lend themselves to fixed-width fonts.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .