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
-
76
votes6
answers20131
viewsDifference between single and double quotes in PHP
What is the difference between single and double quotes in PHP? Yesterday I was working with a string from a google json I used explode('\n', .. to separate a string. When I used the explode in "Mon…
-
52
votes2
answers36638
viewsWhat is the difference between SASS and SCSS
I have been reading about SASS for some time and it provides a powerful feature set for CSS as variables, mixins and the like. And at the same time I see the term SCSS. What’s the difference between…
-
45
votes5
answers56754
viewsWhat is the difference between syntactic error and semantic error?
The concepts of syntactic and semantic error are found in books and other programming materials. However, always generate doubts for those who are starting. In a practical way. What is the…
-
33
votes1
answer2909
viewsHow do Python decorators work?
The @Elizeu Santos asked in the group Python in facebook Portuguese the following: "Talk guys, I’m studying python and something I don’t understand are the decorators. I faced them making the flask…
-
24
votes4
answers1788
viewsAre Getters and Setters mandatory or facilitators?
Lately I have read some Java books, but there is a part that makes me confused in this type of methods accessors - gettters and setters. The point is: I am required to write in this type of methods,…
-
19
votes6
answers2856
viewsCan not use "{ }" IF keys in PHP cause problems?
Usually for checks that modify only one line I have avoided the use of keys, because PHP accepts this method, but I rarely see codes from other programmers like this... Examples My method…
-
18
votes1
answer201
viewsWhat does _ in C#mean?
I was servicing a system until I came across the following code: object auth; var authContext = HttpContext.Items.TryGetValue("SystemQueryContext", out auth); var result = await…
-
17
votes2
answers1662
viewsIn HTML5, should null elements be closed with ">" or "/>"?
In HTML 5, there is a series of null elements, which according to the specification (English) and examples given (English) by W3C, they are closed using only >: Elementos Nulos area, base, br,…
-
16
votes2
answers7005
viewsWhat are the differences between die, Exit and __halt_compiler?
What are the main differences between die, exit and __halt_compiler?
-
15
votes2
answers298
viewsDoes the syntax '//' have any special meaning?
I was using Notepad++ (v 6.5) to write a javascript file when I noticed the following: I wrote a comment line starting with ///, three instead of the usual two. When running this line seems to be…
-
15
votes3
answers2003
viewsIn PHP the correct is Else if or elseif?
In PHP, the correct is else if or elseif? What’s the difference between them? The language allows writing everything together and separately, and apparently the results are identical…
-
15
votes4
answers426
viewsContest question: logic error and semantic error?
I participated in a contest and fell the following question: 33 - Analyze the algorithm and check the correct option for this algorithm. Algorithm Calculo_media: Var N1, N2, MEDIA: Inteiro Início…
-
15
votes2
answers310
viewsGo with a ";" at the beginning of the loop, which means
I picked up a code with a code like this: for (; indField > 0 && indMask > 0; ) What does that mean ";" at the beginning and end of the command?…
-
15
votes1
answer1419
viewsWhat is the advantage of semicolons in programming languages?
I know that in programming languages like Java and C#, the semicolon indicates the end of the instruction, as in the example below, in C#: System.Console.WriteLine("Hello, World!"); However, there…
-
14
votes2
answers2787
viewsWhat is syntax sugar and how does it work?
I have seen in some blogs the use of that term and would like to know: 1) The real meaning of this expression and; 2) How a syntax sugar as the example below in the language java? for (Foo foo :…
-
14
votes2
answers1691
viewsWhat is the advantage of using languages you compile for other languages?
We were discussing in Stackoverflow’s chat about languages like Moonscript and Coffeescript. They are two languages that compile into other languages. Moonscript for Lua and Coffescript for…
-
13
votes1
answer292
viewsWhat is the difference between "using" and "using Static"?
In a question I asked about C#, @Maniero answered me and put an example code in Dotnetfiddle. The code is this: using static System.Console; public class Program { public static void Main() { var…
-
13
votes3
answers4688
viewsWhat is the difference between Function() {} and () => {}? Why doesn’t $http.get work?
When I use $http.get('/products').then((response) => { this.products = response.data; this.allProducts = response.data; }); the page is loaded with the products in Google Chrome, but when I use…
-
12
votes2
answers2445
viewsWhat is the syntax for searching with array as parameter in Mysql?
What is the correct syntax, if possible, to pass an array as parameter, using the FIND_IN_SET more or less in this idea: SELECT c.cpf FROM tbl_cliente as c WHERE FIND_IN_SET(array, c.cpf);…
-
12
votes3
answers5129
viewsWhat is the difference between using single and double quotes in C#?
In PHP, when we use single quotes or double quotes, both forms have the functionality to declare a string. There is only one small difference. I am now starting a study with C#. When I went to try…
-
12
votes2
answers286
viewsWhy does the exchange of values via de-structuring not work if we do not use semicolons?
We know that the semicolon is optional in Javascript, even always prefer not to use it. If I want to exchange values between two variables, via unstructuring, I can do: let a = 11; let b = 22; [a,…
-
11
votes2
answers17877
viewsWhat are the syntax of the for loop in java?
Hello! Everyone programming in Java should be tired of using loops for, that almost always has a syntax similar to this: for (int x = 0; x < y; x++) { ... } I was analyzing some codes and came…
-
11
votes2
answers1331
viewsRuby - What’s the difference if you use two dots or quotes in a string?
In Ruby I can write some things in two different ways: I can do this: :algo Or this: 'algo' What is the difference?
-
11
votes2
answers262
viewsHow to parse syntactically malformed HTML?
As part of a procedure, I need to extract the contents of a table present on a page. I’m using Curl to get the raw HTML data and the Simple HTML DOM Parser to parse and process HTML. <?php //…
-
11
votes2
answers437
viewsIs declaring a class named after a reserved word a good idea?
Generally, when we define names for class and functions, there is a concern when colliding with the palavras-chaves of language. The curious thing is that I noticed that in PHP it is allowed to…
-
11
votes2
answers220
viewsMeaning of append syntax
$("#add_city_btn2").click(function() { var city = $("#add_city2").val(); $("#cities2").append($("<option>", { text: city, selected: "selected"})).change(); $("#add_city2").val(''); return…
-
11
votes1
answer199
views"[-4:]" What is this syntax?
I have the following expression: namer = name[-4:] Where name gets a name, but what does that mean [-4:]?
-
11
votes4
answers870
viewsWhy can an if be redundant?
Using a method that returns a boolean the system would determine whether a number is positive or negative. So I did it this way: public boolean isPositive(float num) { boolean positive; if (num…
-
11
votes1
answer469
viewsWhat is the purpose of empty parentheses in a lambda statement?
I created an example of a Lambda statement with no arguments, however, I have doubts regarding the omission of the empty parenthesis () in the statement. Take the example: class Program { public…
-
11
votes2
answers1673
viewsWhat is the purpose of : (two points) in PHP?
I have this question that is leaving me with a flea behind my ear. I don’t understand at all. What does the sign of : two points. Someone can explain me? Example: if ( have_posts() ) : while (…
-
10
votes1
answer165
viewsWhat is the difference between `for x in y` and `Enumerable#each`?
We can iterate an array/list in ruby in two ways: Using the syntax for x in y: > for x in [1,2,3] do > puts x > end 1 2 3 => [1, 2, 3] Using the method .each > [1,2,3].each do |x|…
-
10
votes3
answers468
viewsInclude/Require 'file.php' or Include/Require('file.php')
I know that PHP allows the inclusion of files in both modes, but I would like to know the correct way to use these functions, or if the two modes are correct.
-
10
votes1
answer269
viewsDifficulty in Syntax
I would like you to explain this function, I do not understand this syntax: double sum_arithmetic(double x0, double r, int n) { return n == 0 ? 0 : x0 + sum_arithmetic(x0 + r, r, n-1); }…
-
10
votes3
answers667
viewsWhat are these attributes in the properties?
What are the names of these "attributes" and what are they used for? Examples: in the declaration of a class: [ComVisibleAttribute(true)] public sealed class SerializableAttribute : Attribute in the…
-
10
votes2
answers2045
viewsAre functions and methods in PHP case-insensitive?
Some time ago, by an accident at the time of a debug I realized that PHP makes no difference between upper and lower case when calling a function. Example: print_r($teste); print_R($teste);…
-
10
votes2
answers424
viewsWhat is the purpose of empty command blocks or which do not belong to any command?
A command block is composed of two or more commands between keys {...//Comandos}, I can use them for the following situations I already know: In a if: if(codicao){...//Comandos}. In a for:…
-
10
votes4
answers236
viewsComparison syntax referring to the same variable
Let me give you an example in C#: namespace Compare { class Program { static void Main(string[] args) { string name = "Girl"; if(name == "Girl" || == "girl") //... } } } This form clearly contains…
-
10
votes4
answers5082
viewsWhat does /= mean in Python?
Can anyone tell me what //= means in python? On line 8 of this code has the use of it. n = int(input("Digite um numero menor que 10: ")) aux, reverso = n, 0 while aux != 0: dig = aux%10 reverso =…
-
10
votes1
answer130
viewsFunctionality of ":" in C#
Recently I was developing a C# application with Visual Studio and I came across a somewhat unusual situation: public void Upload(object model) { FOO: var text = "teste"; } In the code, FOO: does not…
-
10
votes3
answers598
viewsWhat is the difference between keys and parentheses in an Arrow Function in Javascript?
What is the relevant difference between keys ({ }) and parentheses (( )) in a return of a function? const example = () => ( ... ); Versus: const example = () => { ... };…
javascript function characteristic-language syntax arrow-functionsasked 4 years, 9 months ago novic 35,673 -
10
votes2
answers224
viewsWhat is the underscore ( _ ) "inside" of a Javascript number?
I realized I can use underscores (_) between numeric literals in Javascript. For example: const testA = 1_000_000_000; console.log(testA); // => 1000000000 const testB = 1000000_0 + '_0_' + 1_0;…
-
9
votes4
answers1531
viewsHow to assign a value to an Enum with binary notation?
To work with hexadecimal numbers, just add 0x in front of the number, this way: var numeroHexa = 0xff1120; The same goes for octal numbers, adding the 0: var numeroOct = 037; But how do you declare…
-
9
votes4
answers199
viewsDifference between syntax to declare a function
Reading this answer, I realized different forms of call for a function using jQuery. The first way would be this: $('#dois').on("click", testar); function testar() { console.log('Teste Dois'); } And…
-
9
votes3
answers189
viewsWhat happens in the expression "$a+++(+$a)"?
I was playing with PHP to see if I could find something that sounded strange with the syntax, inspiring me in the question What happens in 1...1 in PHP?. I just came across the code: $a = 0;…
-
9
votes1
answer450
viewsWhat’s the comma for?
The comma is what? Just a language construct? An operator? Because it exists? This question is based on what was seen in How to return or extract more than one value from a function?. return base2,…
-
9
votes1
answer191
viewsWhat does the [&] operator mean before a function?
I’m trying to read the code of a function that’s defined like this: auto loop = [&](int ntensor, char** data, const int64_t* strides, int64_t n) { ... }; What does the [&] before function?…
-
8
votes2
answers214
viewsWhat happens if I don’t specify the { }?
I own this code that works normally: if($time <= time()) { if($time != 0) $Server->wsSend(1, 'perfect world'); foreach ( $Server->wsClients as $id => $client ) $time = time() +…
-
8
votes2
answers1999
viewsWhy can’t I declare a variable with a numeric before the name?
I’m curious to know why I can’t create variables with a number before the name. I did some tests in Javascript, Actionscript and C#. var 4teste:String = "teste"; //ActionScript, erro! var 4teste =…
-
8
votes2
answers972
viewsWhy only use Return, without returning any data?
Studying the code of a framework I came across the following code snippet: if (file_exists('lib/util/' . $className . '.php')) { include 'lib/util/' . $className . '.php'; return; } What is the…
-
8
votes1
answer80
viewsCan you initialize only a few members of a C array already in your definition?
I know you can do this: int a[5] = { 0, 3, 8, 0, 5 }; or int a[5]; a[1] = 3; a[2] = 8; a[4] = 5; Can you do the same in just one line, already in the definition? IE, you can initialize only a few…