Most voted "syntax" questions
Syntax is the set of rules that defines how the different symbols of a language (natural or programming) can combine validly.
Learn more…268 questions
Sort by count of
-
8
votes1
answer162
viewsWhat is the need to use the suffix "f" in a numerical constant in C?
It is necessary to add f at a value float within the parameters of a if? Example: if (a == 2.5f && a > 2.0f) {}…
-
8
votes2
answers391
viewsC++ (basic): for, references and syntax
My teacher presented this function to us: void escala(std::vector<double> &v, double fator) { for (auto &vi:v){ vi *= fator; } } It serves to multiply all the elements of a vector by a…
-
8
votes1
answer107
viewsWhat does @ do in variable names?
In the response code of this question on Soen I found an unfamiliar statement line on C#. I tested this line and it works, but I didn’t understand the meaning of this character @ behind the member’s…
-
8
votes1
answer460
viewsWhat is " : " (two points) in C#?
I still don’t understand what the two points represent and why this code isn’t running. int soma = 0; int[] lista = { 3, 7, -6, 10, -1, 0, -1, 4}; for (int i : lista) { if (i > 0) { soma = soma +…
-
8
votes3
answers10568
viewsWhat is the difference between using += and =+ in Python?
I’m having a hard time understanding the difference in logic between: x += n And: x =+ n
-
8
votes2
answers139
viewsWhat is the default (Object) for in C#?
Sometimes I come across the keyword default in the C#: object obj = default(object); string str = default(string); int number = default(int); What good is? In which scenario can I apply this?…
-
7
votes1
answer5408
views -
7
votes2
answers855
viewsWhat is the use of declaring variables through braces?
In PHP, variables usually have a pattern to follow in their declaration. According to the manual: Variables in PHP are represented by a dollar sign ($) followed by variable name. Variable names in…
-
7
votes1
answer153
views -
7
votes1
answer2455
viewsWhat is the correct way to declare a main() function?
In some of the research I’ve done, I’ve noticed that there are some different ways to do it, like the examples below: int main() int main(void) void main() // entre outros... I know that statements…
-
7
votes1
answer386
viewsWhat is and how does the repetition of the for in C#?
for (int i = 0; i < palavra.Length; i++) What does each word mean? And how each part of that code works?
-
6
votes1
answer71
viewsWhy can’t I display Messageboxbuttons if it’s not a string?
'Cause I’m having trouble showing off MessageBoxButtons if it is not a string? static void Main() { string texto = "Minha primeira MessageBox"; MessageBoxButtons botao = MessageBoxButtons.OKCancel;…
-
6
votes2
answers213
viewsDifference between ":" and "." in the methods of a Lua table
I came across two different statements that left me confused. obj = {} function obj.Create(name) end function obj:GoGoGo(name) end What is the difference between the declared function and the .…
-
6
votes1
answer179
viewsWhat are digraphs in C?
Based on the question of graphs, what are digraphs? Why were they created? What are the sequences? Current compilers still allow you to use them?…
-
6
votes1
answer584
viewsWhat does this "." point in Python mean?
What does that mean dot between the variable var and index? Example: var = ['João','Pedro','André','Alice'] var.index('André') Has any name?…
-
6
votes4
answers324
viewsInterpretation of loop of repetition
I’m having trouble understanding the following code that is presented as a book exercise. $a = true; $b = -2; $c = 7; for ( ; $b < $c || $a; $b++){ if ($c + $b * 2 > 20) $a = false; echo $b."…
-
6
votes2
answers1288
viewsWhat do "re:" and "im:" mean in Rust?
I want to know what re and im mean/do let mut z = Complex { re: 0.0, im: 0,0 }; I’m learning Rust by the book Programming Rust and this re: and im: it must have appeared before, but only now have I…
-
6
votes2
answers119
viewsC# properties for those who know Java
What a Java programmer needs to know about basic properties (properties) in order to read code written in C#?
-
6
votes3
answers142
viewsMultiple cases on switch with C# 8
On seeing this question about multiple conditions in the switch, reminded me of a problem I had and I couldn’t solve. In C# 8, a new syntax for switch: int num = ObterUmNumero(); var descricao = num…
-
5
votes1
answer370
viewsTypescript syntax
I am studying Typescript but do not understand what this example means: interface Person { firstname: string; lastname: string; } function greeter(person : Person) { return "Hello, " +…
-
5
votes1
answer128
viewsRead tokens in infinite loop
I have a code that reads tokens a text. I’m using Visual Studio 2013 in an extensibility project. When reading the text through scanner and collect the tokens, the program enters an infinite loop:…
-
5
votes2
answers144
viewsJavascript object return syntax
Using the Chrome console I used the following code (valid): function foo() { return { prop: "some value" }; } when the syntax style is changed is no longer valid ({ played to next line): function…
-
5
votes1
answer516
viewsAndroid - Different ways of "setar" a system in objects
Is there a different way (Syntax) to "set" a Switch on an object on Android ? For example, I only know this way: btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v)…
-
5
votes1
answer134
viewsIs there a difference beyond the syntax between Self-invoking-Functions?
I learned three ways to write Self Invoking Functions, Immediately-Invoked Function Expression (IIFE), and I was left with a doubt whether beyond the syntax there is any difference between them.…
-
5
votes2
answers30209
viewsMysql, types of comments
I had already realized that mysql, maybe not even the only case, but I would like an explanation on top of this to be more objective. I have several types of comments that are accepted: 1) -- ESTA…
-
5
votes2
answers168
viewsClause similar to Mysql LIMIT in MSSQL
I need to run the query below in PHP with SQL Server, however I cannot use the clause LIMIT absent in darlings microsoft. $SqlTabelaAtual="SELECT * FROM BusinessCadTabPreco RIGHT JOIN…
-
5
votes1
answer104
viewsIn PHP 7, can the class method contain a keyword name? Is that good or bad?
PHP 7 has launched a number of innovations for the PHP language. I even noticed that classes can now have keyword named methods. The strange thing is that classes cannot have, but methods can (see!)…
-
5
votes1
answer227
viewsReturn 0 on Linux and Windows
I am starting the ADS course and my programming teacher insists on using the return 0 at the end of the function. Most use Windows, I realized that the return 0 is required on Windows but on Ubuntu…
-
5
votes1
answer1089
viewsHow does the for(;;)work?
It’s probably duplicated, but I didn’t find it here on Sopt, and I don’t know how to Google. How the loop works for in that syntax? for(;;) { //... }…
-
5
votes2
answers120
viewsHow to use C#quotes?
I’m starting to program in C# and I’m feeling some difficulty with quotation marks when I need to paste some text. In Python I could use the triple quotes to paste some text that there was line…
-
5
votes4
answers197
viewsCorrect syntax way in object instance
In the instance of an object, we can: Pessoa pessoa = new Pessoa(); and we can also: Pessoa pessoa = new Pessoa(){ Nome = "Nome", Id = 0, Situacao = true }; What is the best or most correct way to…
-
5
votes2
answers389
viewsWhat is the function of the keys { } in this interpolation?
class MyStateFull extends StatefulWidget{ MyStateFull(this.nome); final String nome = 'Maria'; @override _ContadorClique createState() => _ContadorClique(); // @override //…
-
5
votes2
answers64
viewsIs expression-bodied recommended? Is there a performance difference?
The extent to which it is recommended, or even good practice to use Expression-bodied? I know that the Expression-bodied allow properties, methods, operators and other function members to have…
-
5
votes3
answers387
viewsIs there more than one way to use "if"?
const sequence = { _id: 1, get id() { return this._id++ } } const produtos = {} function salvarProduto(produto) { if (!produto.id) produto.id = sequence.id produtos[produto.id] = produto return…
-
5
votes2
answers2215
viewsWhat is the difference between using a "Constraint" in "Foreign key" or not?
When creating a table in Mysql I used to create fields CONSTRAINT FOREIGN KEY how are you following to create the foreign key: CREATE TABLE socio ( id_socio INTEGER NOT NULL, nome VARCHAR(256) NOT…
-
5
votes1
answer67
viewsWhat is the syntax that comes before the variable name in function parameters?
Reading the PHP documentation I came across the following example: function bar(A $a = null, $b) {} // Ainda permitido function bar(?A $a, $b) {} // Recomendado I did a little digging and figured…
-
5
votes2
answers104
viewsDifficulty in interpreting Arrow functions that return Arrow functions in Javascript
I was seeing Javascript dependency injection and came across the following syntax: () => () => {} I know that () => {} is a Arrow Function which, in short, is a different way of creating a…
-
4
votes2
answers3180
viewsParse error: syntax error, Unexpected ''
I want to print the value on the screen after the PHP result. public function iniciar() { $msg = ''; $oneclick = null; # login... $this->login(); if ($this->logado()) { $oneclick =…
-
4
votes2
answers363
viewsError in Javascript code
I have a code snippet that searches a Json for the field called campo, and inserts it into an array, which cannot have repeated values. My array always returned Undefined and it took me a while to…
-
4
votes1
answer336
viewsWhat is the purpose of { } (keys) to be used to delimit PHP code?
In PHP, you can use the keys in any code snippet, for example, to separate blocks aesthetically. Example: { $a = 1; } { class X{} } { { function x() {} } } In these examples, none of them an error…
-
4
votes2
answers35
viewsStructures and selection of conditionals
Good afternoon! I’m doing a program that reads various cow data: among them age, production, etc. However, I am in doubt about how I can interrupt the event when typing code =0. As it is in the…
-
4
votes2
answers212
viewsWhat is the # (fence) in the Lua language for?
I’m watching this one tutorial about creating a game and came across something I didn’t understand about the language Lua. There is an excerpt from the code where there is the following expression:…
-
4
votes1
answer125
viewsWhat happens on these lines in C++?
This is an Encoder reading routine that detects which direction of Encoder rotation. The references are left and right pins appreciated as MSB and LSB bits. The Code works perfectly, but I do not…
-
4
votes2
answers3911
viewsWhat is the difference between data types Enum, struct and Union in C?
I am reading the GNU’s C manual and I’m in the data types section and I notice a certain similarity between the types enum, struct, and union. Is the syntax the same, or is there something that…
-
4
votes3
answers120
viewsWhat is the syntax of literal objects in Javascript?
Can anyone help me with this structure? I don’t know what it is or how it works. var variavel = { teste1: '1', teste2: '2', teste3: '3' };…
-
4
votes1
answer2845
viewsWhat is the correct way to declare a struct in C?
Also how to rename data types with structures? I have doubt about it because of a Windows Manager that I use has the following code: typedef struct exem exem; struct exem { tiposdedado variavel; };…
-
4
votes0
answers40
viewsDifference in Javascript array declaration
What is the difference between these two forms? var a = []; var a = new Array();
-
4
votes0
answers40
viewsWhat is the purpose of using "{ }" keys to access the property of a class?
I was doing some tests with the magic method __get PHP and discovered a different way to access class properties, which is by using keys { }, see: return $this->{$bar}; I can also access the…
-
4
votes1
answer496
viewsArray in PHP using () or []?
I always use the parentheses to define an array in PHP, such as: $array = array('a','b','c'); But once in a while I see some codes here using brackets, like: $array = ['a', 'b', 'c']; However, if I…
-
4
votes1
answer161
viewsWhat are other pass applications?
In the documentation the statement pass is defined pass is a null operation. When executed, nothing happens. Useful as a placeholder when syntactically a statement is required, but no code needs to…