Posts by Maniero • 444,682 points
6,921 posts
-
10
votes3
answers13060
viewsA: How to add all the numbers in the sequence in while?
If you want to add it up you should put it in the code. So you need a variable, obviously starting from 0, that takes the sum, and you need to add the new number to each step (the increment in each…
-
1
votes4
answers361
viewsA: Comparison between random number and typed number never says it’s right, even though the numbers are equal
I think this is what you want: from random import randint if int(input('Digite um número: ')) == randint( 1, 2): print ('Você ganhou!') else: print ('Você perdeu!') Behold working in the ideone. And…
-
5
votes2
answers441
viewsA: When I use the __Construct method do I not need to use get; set?
We have no way of knowing. And that is the only correct answer to that particular question. One thing people don’t understand about object orientation is that it’s not a way to apply cake recipes…
-
1
votes1
answer98
viewsA: Should failed completed transactions persist in the database?
Durability is a property that must be guaranteed every time the transaction is completed, no matter what happens outside the transaction. So D is the right one. The transaction is only completed in…
-
4
votes1
answer379
viewsA: What is the difference between metaprogramming and reflection?
I disagree with the definition of Wikipedia. The metaprogramming text seems to be a little better. Reflection is a mechanism which gives information about the code itself and allows it to be…
-
2
votes1
answer104
viewsA: Why does adding a variable, property, method, etc. to a string work?
Because this happens, the compiler performs type conversion to string automatically? How does it work? Since all types have a textual representation, even if it does not produce the expected result…
-
11
votes3
answers3647
viewsA: What are the differences between a source editor, text editor and an IDE?
Text editor is to edit unspecified texts, has nothing to do with programming, although a code can be written in a text editor. A code editor is specialized, has resources that help in coding, there…
-
1
votes1
answer75
views -
7
votes2
answers3207
viewsA: What are the differences between ASP.NET MVC and ASP.NET Razor Pages?
The first thing you need to understand is that Razor Pages is like MVC, it’s not a new technology, it totally depends on MVC. It is a simpler way to use the MVC by joining the VC in a single unit,…
-
4
votes1
answer270
viewsA: What is the difference between mixins and inheritance?
I am increasingly convinced that all these terms are a little fragile. It is common to mean different things to different people/communities. What I understood until today is that the inheritance…
-
2
votes2
answers222
viewsA: What are the character types generated by the password_hash() function?
Give a read on documentation. Are you seeing the salt (understand more about it), this part is not part of the hash generated. Generally speaking it does not matter what is being generated. If the…
-
10
votes1
answer521
viewsA: What are the differences in ". NET"?
ASP.NET is just one part of that frameworks is not part of the CLR. .NET Framework died, the rest of the paragraph no longer matters or is no longer true (more at the end of the answer). It only…
-
1
votes1
answer37
viewsA: What are the means of connections a C# application can have with SQL Server?
In theory you can have as many as you want to create. You can create one, you can buy from third party suppliers or get some open source project. The most efficient, until proven otherwise is the…
-
3
votes2
answers290
views -
13
votes3
answers4835
viewsA: It is possible to concatenate numbers of type int
There is, but the algorithm that works in all cases would be complex, almost always pays more to use the string to make the concatenation. So if you’re expecting an instruction or a ready-made…
-
2
votes1
answer175
viewsA: How to get the number of lines from a Stringlist and apply?
Turn into a for and have control over the index. public class ScoreBoard implements Listener { @EventHandler public void pj(PlayerJoinEvent e) { /*tipo de retorno do getStringList*/ list =…
-
3
votes1
answer434
viewsA: How are modifiers implemented in Typescript?
The Typescript compiler generates a JS code and can be seen as it implements. It can do web-based. class Person { protected name: string; constructor(name: string) { this.name = name; } } class…
-
4
votes3
answers116
viewsA: Why is it not possible to assign a string vector after being declared a character?
It is possible, but it does not do what you want. The error there is that it accesses an area of memory that it should not. A array is always accessed through an address. The value of the variable…
-
6
votes1
answer256
viewsA: Which of these 3 PDO codes has the best performance?
If performance is relevant to your application use a compiled static typing language and preferably use the zero-cost abstraction philosophy. Type C, C++, Rust, eventually C#, Kotlin, Java, D, Go,…
-
4
votes1
answer730
viewsA: Use Import or Include in C/C++?
Do not use #import, it is out of standard, at most use #pragma once if you want to ensure that inclusion occurs only once. Behold: How the Include directive works? What’s the difference between…
-
2
votes1
answer2206
viewsA: Math.Round method does not round correctly
There are two problems in the code. The first is that the adopted rounding pattern is the same. If you want to change you have to configure with the enumeration MidpointRounding. But in this case it…
-
8
votes2
answers3493
viewsA: Difference between primitive type and object in Java
Let’s understand In programming, what is an object?. So all data is objects. There is a misconception that there are only objects in object-oriented programming. If this were true, what would you…
-
15
votes4
answers5616
viewsA: What kind of application can I use Mongodb in?
Of course it’s bad, and that goes for any technology. Can you use it in any application? Probably yes, the question is how good the result will be and how much effort you will have to make. Do you…
-
5
votes1
answer194
views -
2
votes1
answer89
viewsA: How to perform in systems?
The biggest performance gain will always be given by the programmer. A wrong choice for changing performance easily by at least 10 orders of magnitude. Using right algorithms is always the best way.…
-
4
votes2
answers70
viewsA: Conditional operator ?: not working
Conditional operator accepts only expressions and does not statements, so it doesn’t work. Both can best be written using conditional operator only at the part that actually varies, and that is an…
-
3
votes1
answer155
viewsA: Array and type being created
An object of what type is created? ns will have an object of type array of int and cannot be changed. Note that because it is a type by reference the variable will have a pointer to the real object.…
-
4
votes2
answers123
viewsA: Property with private set
Let’s see how this code is generated: .class private auto ansi '<Module>' { } // end of class <Module> .class public auto ansi beforefieldinit C extends [mscorlib]System.Object { //…
-
4
votes2
answers778
viewsA: Empty if declaration in function
I think this is what you want. def filtro(p): if p > 6: return True return False x = int(input("Valor de x")) if filtro(x): print(x) x = int(input("Valor de x")) if filtro(x): x = x * 2 print(x)…
-
2
votes1
answer169
viewsA: How do you create an optional parameter in a class method?
It’s the same thing: #include <iostream> class Exemplo { public: void nada(int a, int b = 0); }; void Exemplo::nada(int a, int b) { std::cout << b; } int main() { Exemplo x = Exemplo();…
-
2
votes3
answers219
viewsA: Add number in array and list it
The problem with the code is that it’s not adding up where it should, sum up into a variable that even has a value. For some reason I believe you’re thinking that the array is a guy who keeps on…
-
3
votes1
answer60
viewsA: For don’t go through the whole list
I think this is what you want: for (LancamentoCaixa lancamento : listaCaixaAbertos()) { lancamento.setFechado(true); salvar(lancamento); } I put in the Github for future reference. Whenever possible…
-
7
votes2
answers265
viewsA: What is the globally accepted standard in programming languages?
In the Portuguese language in Brazil we use ABNT if we want to elaborate a highly correct and precise text before the norms, and to make itself understood before the words we use the dialectic. In…
-
5
votes3
answers964
viewsA: Use of 'break' in Javascript
You can use what you call labeled break. Deep down it’s a drop a little more restricted. It tells you where the code should go when it breaks, and it obviously needs a "tag" in the code telling you…
javascriptanswered Maniero 444,682 -
4
votes1
answer658
viewsA: error: field has incomplete type
The error already tells the problem. To set MinhaClasse need to define MinhaClasse, and goes into loop infinite, has no solution. Actually there is a solution, is to turn the field into a pointer,…
-
3
votes3
answers100
viewsA: Convert decimal to ushort
Essentially I shouldn’t be doing this for two reasons: It is probably losing data since a decimal is not a positive integer. It may be, but there are no guarantees. Of course, you can check before…
-
9
votes2
answers3367
viewsA: What are the differences between Viewbag, Viewdata and Tempdata?
Viewbag It is a dynamic object with properties created in the controller and accessible in the view, after which it disappears. It maintains the type of each member, although the compiler cannot do…
-
2
votes2
answers161
viewsA: How to manage threads in C#?
I’m developing a project and I think I’m going to need multithreading. So see this to make sure you really need it. Most people believe that thread is something magical that makes a code run faster.…
-
3
votes1
answer54
viewsA: Why are the string characters being printed as integer numbers?
Documentation of the function encode() says that a returns array of bytes, so this is what you have, a collection of bytes, not of characters. Either you should not use this function or you should…
-
4
votes1
answer94
viewsA: Why is the exit 16?
That’s exactly what the compiler is saying, there is no way he can guarantee what will happen with this expression that generates side effects, there is nothing in the specification that requires…
-
4
votes1
answer217
viewsA: "isdigit()" with 0.00 does not work
Because it is not composed only of digits. The dot is not a digit. Ask the right question you will get the right answer. try: resultado = Decimal(numero) except ValueError: print('Não foi possível…
-
10
votes2
answers1752
viewsA: Is it possible to evaluate a ternary expression with 3 possible values?
It is possible to use nested conditional operators, but is discouraged by decreasing readability, although it can help a little: resultado = total > 5 ? 5 : total < 5 ? 1 : total > 0 ? 0; I…
-
18
votes5
answers625
viewsA: Allow or not allow end spaces in passwords?
I return the question: what problem you see in considering white space? I don’t see any technical problems. Maybe from UX. But then it’s relative, it depends on the public. Space is a character like…
-
3
votes1
answer134
viewsA: Difference in Java casting
It’s very simple, the first works and the second doesn’t, it doesn’t make sense to make a Parsing in an integer number, only in strings. So documentation shows that only one string. Alias the method…
-
3
votes1
answer79
viewsA: line 17, in <module> print(f'{a[str(x)]}: {str(n)[r-c]}')
The code has several errors. I think this is what you want: a = {'0': 'Milhar', '1': 'Centena', '2': 'Dezena', '3': 'Unidade'} while True: n = input('Digit a number: ') #só pede a digitação if…
-
7
votes3
answers8551
viewsA: Get the number of digits in a number
It is always better to do it with math (well, it seems that Python is not so much, it is still good, but it is slow almost equally). I made one use mathematical function ready and another without…
-
2
votes1
answer502
viewsA: How to return the last element of the array using the for method?
The code has several errors. The variable is not initialized i and has to initialize with the number of elements minus 1, since it starts from scratch. The ending condition of the loop should be as…
-
4
votes3
answers161
views -
5
votes2
answers2358
viewsA: Show only the last word of a string
The simplest, correct and most performative form would be this: #include <stdio.h> int main () { char frase[200], palavra[200]; scanf(" %[^\n]s", frase); int j = 0; for (int i = 0; frase[i] !=…
-
1
votes2
answers1299
viewsA: How to format a Double by swapping a semicolon and keeping 2 decimal places in VB.NET
A value Double is only a number, it has no formatting, it is only possible to turn it into String applying a formatting. This formatting should use a culture, in this case the Brazilian. Imports…