Posts by Maniero • 444,682 points
6,921 posts
-
4
votes2
answers68
viewsA: Comparison of numbers read with "io.read()" does not result in true as expected
You are comparing text with number, so they are different values, so it is false and does not enter the if. That is correct: x = io.read() if x ~= 0 then print(x .. " diferente de 0") end if x ==…
-
2
votes1
answer81
viewsA: Condition does not work in a Setter method
Because 20.000 it is not what it imagines to be. If you want a literal of monetary value and so be able to compare with a type decimal should use then 20M. You don’t have to put zeros after the…
-
7
votes1
answer107
viewsA: Why does the class accept parameter and the method does not?
There is no class that accepts parameter, class has no parameters. There is an object constructor of a class called init() which accepts to receive an argument because it is declared that this…
-
4
votes1
answer71
viewsA: What is Mongodb and why should I, as a front-end dev, adopt it instead of good old Mysql?
It is a database mechanism within the spectrum called Nosql, meaning it does not seek to organize information tabular and related. You can read more about at What is a Nosql Bank? How it works?. And…
-
3
votes1
answer113
viewsA: Is there a difference between using discard or ignoring the value returned by a method?
I would say that legibility is improved, at least from a certain point of view, it can be subjective. The second way is more explicit and this has its legibility advantage, although one can say that…
-
2
votes1
answer93
viewsA: Is the implementation of an interface part of the encapsulation or heritage pillar?
Encapsulation refers to putting everything together in a capsule in the same location, so strictly the interface mechanism itself has nothing to do with that. But you can interpret in some way that…
-
3
votes3
answers171
viewsA: Why does it return "Undefined" because it has an "if/Else"?
He doesn’t get into the else at any time, and that’s the problem, in the else returns something, when it enters the if he returned nothing, which is undefined, and that is what needs truth. I think…
-
2
votes1
answer60
viewsA: Parser Generator and Transpilator what’s the difference?
I will not talk about transpilation because it has already been explained in the question linked and because the subject has nothing to do with the other doubt, is like asking what the difference…
-
1
votes2
answers63
viewsA: Segmentation failure when printing white space C
There are several problems with this code. The scanf() has trouble reading texts with spaces so I switched to something that reads correctly. It doesn’t make much sense to return the first space,…
-
1
votes2
answers736
viewsA: Error: non-static variable this cannot be referenced from a Static context
Do what the error message shows is wrong. If it says there is no static variable it is because it needs the variable to be static, right? So make the variables static, after all they are accessed in…
-
1
votes1
answer53
viewsA: Why do different types of variables give different results when modified in a function?
In one of the functions what is going through is a value that is in the variable, in the other is passing a pointer indicating where is a value that matters. In the first who is copied to the…
-
5
votes3
answers149
viewsA: What is data modeling (data Modeling)?
What is data modeling (data Modeling)? Data modeling is the definition of how the data structures of an application should be mounted. Then the developer defines what data it makes sense to have in…
-
3
votes1
answer204
views -
5
votes2
answers73
viewsA: How to use multiple unique "if" in PHP?
You have 3 ifindependent and not a if only, which is what it seems to desire, and as they all change the value of the same variable only the latter will prevail, whether true or false. If you really…
-
8
votes2
answers147
viewsA: In Java because (250 >> 4) is more optimized than (250 / 16)
Have you tested? Someone talk and be true will a big difference. I’m not going to say and I don’t have an environment right now that I can do a proper test to show whether this is really true or…
-
3
votes2
answers81
viewsA: What does the "retn" statement mean with an argument?
When the code will return from a routine it must specify how many bytes it should return to the stack by changing the Stack Pointer (SP) register. That’s the number there. Note that the numbers are…
-
2
votes2
answers95
viewsA: How to print a class in c++?
The printing method already makes the impression, it is not a stream of data or even it even returns some data, you should call it directly and not in a cout waiting for a stream. The impression…
-
8
votes2
answers337
viewsA: How do "for in, for of, foreach" loops traverse the array?
The noose for is a project pattern to repeat commands with a startup, a step that will always run at each iteration and a condition that will determine when to stop repeating. Some languages have…
-
3
votes1
answer40
viewsA: Pass parameters to a function being passed from parameter to parameter
Can’t do exactly that, can something close. The function signature cb does not predict that it has parameters, so you cannot pass a function that has this parameter. One solution is to change…
-
6
votes2
answers165
viewsA: What is the purpose of ? (question mark) in calling a function?
What is the purpose of ? in a function? Coding style and naming convention only. What is the relationship of ? with the signature of the function? No real, just a conventional. What the ? plays a…
-
1
votes2
answers326
viewsA: PHP indentation in HTML
Not much, you have to choose which one will make more sure the code you read every day, or the code that goes into the browser you never read. If you want to do the second you can do something like…
-
3
votes2
answers117
viewsA: Write a program that reads a character and displays the boolean value True (true) if it is a digit between ' 0' and ' 9' if not False (false)
There are some mistakes, and some things too complex. You are transforming the character typed in its number into the table that determines which are the characters (ASCII or Unicode). So you have…
-
3
votes2
answers290
viewsA: When printing an array elements are not shown
When you encounter a problem like this look in the documentation how that method works. In fact, do not use a method without reading and understanding all its documentation and what is related.…
-
3
votes1
answer67
viewsA: Global variable does not change the value
The biggest reason is that you declared the function but did not call it, so it is not executed and nothing happens. So it works: def teste(): global res1 res1 = input().strip() teste() if res1 ==…
-
4
votes3
answers81
viewsA: Confusing behavior in changing the value of variables in js functions
This has nothing to do with closure, including this way that has spread around declaring the function is horrible because it gives the wrong idea of what it is, when it has a simple function, use a…
-
13
votes2
answers262
viewsA: CRUD is an architecture standard?
It involves history. The term is used closely related to the database, but also for screens that behave within the basic operations that a database performs. The original term was CRUD Matrix. It…
-
4
votes1
answer45
viewsA: Print with variable or by direct account?
There is no right way. It is a matter of style and even need. I tend not to create variables unnecessarily. But in complex calculations that have a clear meaning in more complex applications I can…
-
3
votes3
answers138
viewsA: The main function and its arguments. How does it manage to assign to its argc and *argv[] arguments the parameters passed via terminal?
First read What is the difference between parameter and argument?. It’s a bit complicated to explain this without writing a book talking about operating system and how an executable works and memory…
-
6
votes1
answer101
viewsA: Improve performance in iteration
If the desire is performance forget the LINQ, it is not fast, it lets write more expressively, or cute or short as some will say, but it is not fast. It’s not tragic, but it’s not for speed, take it…
-
1
votes1
answer84
viewsA: Are inheritance derived classes different tables in Mysql?
It is not so simple to transpose the object-oriented model of programming languages into the relational database. Not even in Dbs that have inheritance like Postgresql. In fact, don’t waste time…
-
3
votes1
answer105
viewsA: For in the C language
This code is misspelled and gives a wrong idea of what it does. Written in a better way: #include <stdio.h> int main() { int vet[7] = {0}; for (int i = 0; i < 7; i++) printf("%d ", vet[i]);…
-
1
votes1
answer50
viewsA: `<=': comparison of Integer with String failed (Argumenterror)
You have not saved the converted value to integer anywhere, then the conversion is done and the result is thrown away and the variable remains one string. The ideal is to do the conversion at once,…
-
2
votes1
answer38
viewsA: Why in a generic-type method extension do I not need to spell out a type when calling it?
The question should be Why in a generic-type method extension I don’t need to spell out a type when calling it? Because the answer is precisely the inference that the compiler makes. The…
-
2
votes2
answers80
viewsA: How do I use the for command to solve the same problem?
The for exists to go through data collections, so you have to generate a collection of numbers starting in quantity, going up to 0, with the step of each variation of the number being negative to go…
-
1
votes1
answer44
viewsA: Is there a difference between Task.Fromresult and Task.Factory.Startnew?
There is some difference between these implementations? The first only creates a result of a task, it does not perform a task. If you need to perform a task it should not be used. His function is to…
-
5
votes3
answers98
viewsA: Why is the expression ``` == '`' true?
The backslash is just an escape character, that is, then comes a special character, in practice there is only one character there, the bar is only syntax to indicate the differentiation. It is not…
-
3
votes1
answer189
viewsA: Why does a program compiled for Linux not run on Windows?
Why executables are different between operating systems Linux and Windows run on several processor architectures, not just x86. Linux in a larger amount. The architecture that runs most nowadays on…
-
1
votes1
answer103
viewsA: Why in Python are there functions where the parameter should be placed between parentheses and others should be placed with a dot and the function name?
The first syntax is considered more imperative, that is, the function is what matters most, so it comes first, and the object that will be manipulated within it is only one argument of function. The…
-
1
votes1
answer47
viewsA: My if Else doesn’t work on the Console.Readkey, so he was doing a little program he’s running but he "jumps" the commands inside if Else
There are several errors in that code. I will correct some, but not all, mainly the object of the account that should have constructor, methods that do certain operations instead of accessing the…
-
4
votes1
answer75
viewsA: Compilation error on non-static element reference
At the moment the class is instantiating Teste in the static field need to create the implementation of the abstract method and this is what it does correctly, after all abstract classes cannot be…
-
3
votes3
answers230
viewsA: Remove lowercase letters from a list
You cannot remove elements from a collection with a for because it invalidates the iterator. Or you have to do it manually, which is risky if you don’t know how to do it right or you should create a…
-
1
votes1
answer58
viewsA: String Return
The undefined error is another problem because you have not defined the function you are using. The real problem reported in the question is that it is returning multiple values instead of making a…
-
3
votes3
answers144
viewsA: Check magic numbers (those whose square root is a prime number) within a range
You are making 4 conditions and concatenating them all with the operator or. So far so good. The first works as expected. The problem comes in the next. The second condition is only 3, nothing more.…
-
9
votes1
answer295
viewsA: Difference between using Generics and "any" in Typescript?
The ideal is not to use any. You can live without it, only some cases can be more work, so there are rare cases that can be interesting to use. any is to go back to being Javascript and every…
-
3
votes2
answers231
viewsA: sizeof does not work to determine the size of malloc
The calculation you’re making is only for one array with defined size at compile time. Although it is using a constant in dynamic allocation it is potentially unknown and does not work. The operator…
-
0
votes2
answers259
viewsA: Invoke child class method in C++
You’re trying to make inheritance on a type by value, it doesn’t happen as you expect. To do polymorphism in type by value use a mechanism of template or something more complex, but don’t try to…
-
3
votes2
answers159
viewsA: Why does this function return Object and not array?
The fact that you wait does not mean that it should happen. The expected for me that I read the language specification is to return object even. See the list of types that Javascript has. Where is…
-
2
votes1
answer68
viewsA: Why am I getting the "0" return regardless of the entered input?
The biggest problem is that it is not printing the result, it is being returned. Return and printing are different things. The code was discarding the result that the restornava function. But I…
-
4
votes1
answer199
viewsA: What is the difference between "value types" and "Reference types"?
It would be interesting to read Memory allocation in C# - Value types and reference types. Your example is wrong, the two variables have types by value, maybe that’s why you don’t understand. In n1…
-
2
votes1
answer48
viewsA: How does a script work on a web page?
You are using a function that works with a mechanism called callback. Then you record the code you want to run in a function, in case the addEventListener(). Inside there is a code that will know…