Questions tagged as 'sintaxe'

1
answer

What is the difference between 'for x in y' and 'Enumerable # each'?

We can iterate an Array / list in ruby in two ways: Using the for x in y syntax: > 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| > puts x...
asked by 17.02.2014 / 23:19
2
answers

functions and methods in PHP are case-insensitive?

Some time ago, due to an accident at the time of a debug I realized that PHP is not case sensitive at the time of a function call. Example: print_r($teste); print_R($teste); Print_R($teste); The same thing happens for the methods of...
asked by 11.02.2015 / 15:24
2
answers

C ++ (basic): for, references and syntax

My teacher introduced this role to us: void escala(std::vector<double> &v, double fator) { for (auto &vi:v){ vi *= fator; } } It serves to multiply all elements of a vector by an already predefined factor. I h...
asked by 07.05.2018 / 13:20
1
answer

What does @ do in the name of the variables?

In the response code this question in SOen I found an unfamiliar statement line in C #. I tested this line and it works, but I did not understand the meaning of this @ character behind the member name. // declara "@foo" como uma strin...
asked by 08.08.2018 / 06:49
1
answer

What does "::" mean in C ++?

I have doubts about using the colon :: , used to do class implementation, [tipo] [classe]::[método] . It is also used, for example, in std::cout . What exactly would these two double points be and what do they serve for?     
asked by 18.09.2015 / 04:19
1
answer

What is the comma for?

The comma is what? Just a construction of language? An operator? Why does it exist? This question is based on what you saw in Returning or extracting more than one value from a function? . return base2, base3, base4     
asked by 06.01.2017 / 12:08
1
answer

"[-4:]" What is this syntax?

I have the following expression: namer = name[-4:] Where name gets a name, but what does this [-4:] mean?     
asked by 05.11.2015 / 23:01
1
answer

Is it possible to initialize only some members of an array in C already in its 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?     
asked by 22.03.2017 / 12:33
2
answers

What is the use of declaring variables using 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. The variable names in PHP distinguish between   upperca...
asked by 31.07.2015 / 20:48
1
answer

Strange property initialization

When reading a tutorial on Entity Framework, I came across an example code where there was a line that, for me, is unknown: Student stud = new Student() { StudentName = "New Student" }; I understand that a new object of type Student...
asked by 02.05.2016 / 16:29