Questions tagged [statements]

In computer programming a statement is the smallest standalone element of an imperative programming language. A program written in such a language is formed by a sequence of one or more statements. A statement will have internal components (e.g., expressions).

A statement is the smallest standalone element of an imperative programming language. A program written in such a language is formed by a sequence of one or more statements. A statement will have internal components (e.g., expressions).

Resources

471 questions
427
votes
17 answers

How to use "pass" statement?

I am in the process of learning Python and I have reached the section about the pass statement. The guide I'm using defines it as being a null statement that is commonly used as a placeholder. I still don't fully understand what that means though.…
Capurnicus
  • 8,171
  • 5
  • 18
  • 11
144
votes
6 answers

"assert" statement with or without parentheses

Here are four simple invocations of assert: >>> assert 1==2 Traceback (most recent call last): File "", line 1, in ? AssertionError >>> assert 1==2, "hi" Traceback (most recent call last): File "", line 1, in ? AssertionError:…
new name
  • 15,861
  • 19
  • 68
  • 114
29
votes
4 answers

What is the definition of cardinality in SQL

My school book Database Systems defines cardinality as follows: The cardinality of a relation is the number of tuples it contains. By contrast, the number of tuples is called the cardinality of the relation and this changes as tuples are added or…
Tobias Schultz
  • 301
  • 1
  • 3
  • 4
17
votes
3 answers

how to use "if" statements inside pipeline

I'm trying to use if inside a pipeline. I know that there is where (alias ?) filter, but what if I want activate a filter only if a certain condition is satisfied? I mean, for example: get-something | ? {$_.someone -eq 'somespecific'} |…
Emiliano Poggi
  • 24,390
  • 8
  • 55
  • 67
17
votes
3 answers

What is the difference between a statement and a function in Python?

Edit: The suggested duplicate, does not answer my question, as I am primarily concerned with the difference in Python specifically. The suggested duplicate is far broader than this question. I have recently started to learn Python. I'm currently…
Gary
  • 1,086
  • 2
  • 13
  • 39
16
votes
3 answers

Why is the function return in C a statement?

An expression generates a value, statements alter the status of the machine, aka, side effects. However, I keep reading that function return is a statement. If I call a function that returns a void, how does that change any status of the machine? Or…
SLN
  • 4,772
  • 2
  • 38
  • 79
10
votes
3 answers

Two PLSQL statements with begin and end, run fine separately but not together?

Just wondering if anyone can help with this, I have two PLSQL statements for altering tables (adding extra fields) and they are as follows: -- Make GC_NAB field for Next Action By Dropdown begin if 'VARCHAR2' = 'NUMBER' and length('VARCHAR2')>0 and…
Twiss
  • 113
  • 1
  • 1
  • 5
10
votes
2 answers

Is there a VB equivalent to C#'s 'continue' and 'break' statements?

For sake of argument, how could I do this in VB? foreach foo in bar { if (foo == null) break; if (foo = "sample") continue; // More code //... }
Jude Allred
  • 10,977
  • 7
  • 28
  • 27
8
votes
1 answer

SQL Statement t1, t2 etc

Im quite new to SQL and I'm just trying to find out what it means when you use t1, t2 or t3 etc... I cant get my head around it and would just like to learn about it. I've tried looking all over google but i've found nothing yet... Can you…
user1847961
  • 117
  • 2
  • 2
  • 8
7
votes
3 answers

ISO C90 forbids mixing declarations and code... but allows it in certain instances?

I am using the following flags (where cc is either gcc 4.2 or clang 8.0): $ cc -Wall -Werror -pedantic -ansi -std=c89 main.c (I know the -ansi flag is a bit redundant in this case) The following gives me the expected error main.c:31:8: warning: ISO…
Karsten Pedersen
  • 419
  • 4
  • 11
7
votes
2 answers

Custom Compound statements in c#

I would like to write my own custom compound statements that have a similar mechanism to using and lock mechanisms where they have code injected at the beginning and end of the statement block before compilation. I have tried searching for…
Gelion
  • 531
  • 7
  • 18
7
votes
2 answers

Does adding a semicolon at the end of `return` make a difference?

The Rust Guide states that: The semicolon turns any expression into a statement by throwing away its value and returning unit instead. I thought I got this concept down until I ran an experiment: fn print_number(x: i32, y: i32) -> i32 { if x +…
sargas
  • 5,820
  • 7
  • 50
  • 69
6
votes
6 answers

Is a line in a Java program the same thing as a statement?

I'm a Java noob. I've only used it for a few days and I'm still trying to figure it all out. In a program, is a line the same thing as a statement?
Benny
  • 71
  • 2
6
votes
2 answers

What is meant by locality of declaration?

I was reading a book and here, a program is given like this - #include #include #include int main() { string filename; // #1 cout << "Please enter name of file to open : "; cin >> filename; …
dukeforever
  • 298
  • 1
  • 7
6
votes
5 answers

Making your own statements

Is there a way to define new statements like def, with, for of my own in Python? Of course, I don't mean to override the existing statements, only create some of my own. If so, how do I do it? Can you point me to good docs on the subject?
Guy
  • 14,178
  • 27
  • 67
  • 88
1
2 3
31 32