Code Block
Several lines of code grouped to work together.
What is a Code Block?
A Block of code is 1 or more lines of code grouped together as a logical unit. The gode is grouped because it logically belongs together and should be executed at the same time.
Some languages use {} to create a block - i.e. JavaScript, Java, C#
//Java
public int add(int left, int right) {
// everything between {} is a block
return left + right;
}
//C#
public int Add(int left, int right)
{
return left + right;
}
//JavaScript
function add(left, right) {
return left + right;
}
Some languages use indentation to create blocks - such as Python
def add(left, right):
# everything indented is a block
return left + right
Level: Novice · More General terms at this level
Updated