Most voted "return" questions
In Programming, the Return statement makes the execution leave the subroutine that contains it and continue from the immediately following point to which this subroutine was invoked. Return addressing is usually saved to a call stack as part of the invocation process of the subroutine. Return statements, in many languages, define the return value of a function.
Learn more…152 questions
Sort by count of
-
152
votes4
answers6835
viewsWhy should I only use a "Return" in each function?
It is common to see the recommendation to use only one return by function/method. But this seems somewhat meaningless and leaves the code more confusing in many cases. See the examples: The way I…
-
20
votes4
answers9040
viewsHow to return 2 or more values at once in a method?
It is common to see examples of methods returning one value at a time. I’ve seen cases where you need to create a class only to package the data and be able to return more values. Use the generic…
-
15
votes8
answers2223
viewsError: not all code paths Return a value
I would like to understand why my code is causing the error not all code paths Return a value using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using…
-
13
votes3
answers4752
viewsWhat is the difference between 'Yield' and 'Return' in PHP?
I have been trying to remove this doubt, but without success. At first glance they seemed to me similar commands or they would be the same thing. After seeing some explanations, I was a little…
-
11
votes2
answers21117
viewsWhat does "Return" do in Python?
What "really" the return does in Python, mainly in recursive functions. Ex. factorial: def fatorial(n): if n==1: return n return fatorial(n-1) * n…
-
10
votes3
answers6900
viewsWhat’s the difference between Return and break in a switch case?
In some situations it is necessary to practice the switch case for optimization and improvement of code. I have an application developed for Android using Java, which in case is used of both…
-
9
votes4
answers12732
viewsMultiple return in C/C++
Is it possible to return multiple values? For example: umafuncao() { int x = 1, y = 2; return x,y; } void main() { int a, b; a, b = umafuncao(); } I’m asking this question because I built a code…
-
9
votes4
answers2878
viewsTwo "Return" in a function
How it works if there are two (+) return in a Python function? It would return the second value, or only the first? Example: def soma(a, b): x = a + b y = 'qualquer coisa' return x return y…
-
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
votes4
answers814
viewsWhy can’t we return a void call in a void return waiting method?
I was doing some C# tests to find out how the return issue works void. I did the following test below and realized that tests 1 and 3 work perfectly, however 2 no. Behold: public class Program {…
-
7
votes2
answers1249
viewsReturning function string directly and with array
What works: void *teste(); int main () { printf("\nRESULTADO: %s\n", teste()); return 0; } void *teste(){ return "Ponteiro"; } What goes wrong: void *teste(); int main () { printf("\nRESULTADO:…
-
7
votes1
answer311
viewsWhen to use Supertype or Subtype when returning the method?
Suppose I have a method called "meuMetodo()" that returns an Object of Type ArrayList<String>, i can make this method declare that returns more concrete or more abstract types: public…
-
6
votes1
answer1353
viewsHow to return or extract more than one value from a function?
integerPower( int y ){ int base2; int base3; int base4; int total; base2 = pow( y , 2); base3 = pow( y, 3); base4 = pow( y, 4); When I call this function (I did not type return because that’s the…
-
6
votes1
answer282
viewsShould we disregard the return of functions in C that already receive the desired value by the parameter by reference?
Looking at the documentation of scanf() I saw that it returns a value, but I see the codes using it without using that return. This is right?…
-
6
votes1
answer1709
viewsWhat’s the difference and benefits of using @@IDENTITY and OUTPUT INSERTED.ID
I’ve always used the @@IDENTITY to get the last inserted identity value, as in the example below. create Proc [dbo].[Arquivos] @IdArquivo int, @IdArquivo_Out int output as begin Set Xact_Abort on…
-
6
votes1
answer4920
viewsIs there a difference between using "Return" or "Exit()" to terminate the "main()" function?
The function exit() closes the execution of the application immediately. The command return makes you quit the function, but when you’re inside the main() will exit the application, including the…
-
6
votes2
answers165
views -
5
votes1
answer615
viewsWhat does the term "String... string" mean in java?
What the term means String... string in Java? And how to elaborate a method that returns a String... as an example: public String... getStrings(){ return String... s;) } I know it’s not like that,…
-
5
votes2
answers393
viewsFirefox claims code after Return
Situation It was performing some maintenance functions on JS. And a certain function I placed a return in the midst of it, for the rest was no longer necessary. On seeing from the comment the rest…
-
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
votes2
answers2603
views -
5
votes0
answers56
viewsJavascript: why does Eval("023") return 19?
I know that the function should not be used indiscriminately, because it has several security implications, conforms can be seen here: Eval is either good or bad? But I was making a simple…
-
4
votes2
answers621
viewsHow do I access the indexes of a vector returned by a java method?
I have a method called vetorVoos which returns a vector of the type NodeVoo and I want to access the indexes of this vector through the method in another class. This is the method: public NodeVoo[]…
-
4
votes2
answers360
viewsPut method return before a "Finally" block
Considering: try { System.out.println("Parte 1"); return false; } finally { System.out.println("Parte 2"); } What will be the output and what happens behind the scenes so that the output come out…
-
4
votes1
answer572
viewsHow to return more than one value using an Asynctask on android?
Briefly, my class that extends an Asynctask, downloads a series of data byte type, then I need to perform some calculations with this data, and finally return all these values to my Mainactivity.…
-
4
votes3
answers388
viewsIs it possible to offer return options in a method?
As far as I know Overload in the creation of methods, which are execution options, example(very simple), a method where you have the option to pass 2 or 3 parameters calling the same function:…
-
4
votes3
answers214
viewsError: "Return should not be followed by an object expression"
I have this function that has a simple registration but is not registering My doubt would be on that return RES; which gives the error message below the code. //botao para cadastrar OS private void…
-
4
votes1
answer213
viewsStackoverflow error when compiling code in C#
I am doing an exercise in C# and I am not able to find the error in my code, because I have already checked the resolution of the problem and I can’t find the difference in the syntax of the code…
-
3
votes2
answers121
viewsCan I return a struct by initiating it into a Return in ANSI C?
Good morning guys, I wonder if I can do something like this... typedef struct Result { int low, high, sum; } Result; Result teste(){ return {.low = 0, .high = 100, .sum = 150}; } I know this…
-
3
votes4
answers3475
viewsHow to return 2 variables of a function
I am accessing a webservice, that has as return: listProdutos[] -> List of all products or null when there are no products When you lose access for some reason, you make an exception, in which…
-
3
votes2
answers3951
viewsFactorial function in C does not return the result
What’s wrong with my code? int fatorial (int n, int num, int fat) { if(num >= 0) { fat = 1; n = num; while(n > 0) { fat *= n; //FATORIAL = FATORIAL*N n--; } } }…
-
3
votes1
answer148
viewsWait variable value to return function
I’m trying to create a function that turns a file into a Data URL. But I am facing a problem: The return value of the function is not what I expected. Just follow my code: File.prototype.toData =…
-
3
votes1
answer601
viewsReturn local function variables
I have two methods: // Apenas define um vetor de 4 posições e retorna ele int *verticesFromFace(int v1, int v2, int v3, int v4) { int vertices[4] = {v1, v2, v3, v4}; return &(vertices); } //…
-
3
votes2
answers1011
viewsReturn with 2 C#Values
I want to give return of two values in c#. My code is like this currently, just returning the imagePath, but I want to return the imagePath and the normalPath at the same time. string imagePath =…
-
3
votes1
answer45
viewsUse closure as return of a function
I need to use a variable of a closure as a return to the function to which this closure is nestled. How can I do this? response must be the return of ajaxRequest(): function ajaxRequest(type, url) {…
-
3
votes2
answers154
views -
3
votes3
answers400
viewsHow to return 2 vectors of different types in C++
I perform a calculation and my result is saved in a vector<int> and a vector<string> How do I make my function return these two parameters in mine main()? int cracking(string chemform) {…
-
3
votes3
answers337
viewsError calling function that returns string in C
I made a program that asks for name and surname to be concatenated through a function: #include <stdio.h> #include <string.h> int main(void){ //Declarando Funçãoo char retornaNome(char…
-
2
votes2
answers3265
views -
2
votes1
answer6363
viewsReturn vector of integers in java
I’m trying to read an array of integers and return the number of ones and the number of zeros, but it always returns at least a zero number, even without me having entered it. Debugging the code,…
-
2
votes1
answer57
viewsDifference between List and and Return in Entity
Hello, I am with a doubt when I will take the data of an SQL query, there is the possibility to pull by list and by Entity, which is would be the "most correct" or the usability of each? public…
-
2
votes1
answer461
viewsIn java, a Void that sums, returns value?
My doubt is about what exactly is a java return. Because I think the sum answer would be a kind of return, this is correct? void soma (int a, int b) { int s = a + b; System.out.println (s); }…
-
2
votes1
answer563
viewsc++ - How to return a value to a previous window in Qt?
Hello, I am developing a project where I will have many calls from new windows and need to recover a value from these windows to the main window (Mainwindow). The problem is that it becomes…
-
2
votes2
answers1450
viewsC#url shortener
I’m adjusting a code in c# for a url shortener api to send in the sms inside an application, it’s all working, but the out-of-code api works, but within the code the Return comes back nothing, I’m…
-
2
votes2
answers5533
viewsReturn string in C for manipulation outside the function in which it was declared
I must develop a calculator that reads strings in the algebraic form of the complex number operation. I need to manipulate the "main" vector outside the function in which it was declared (receives).…
-
2
votes0
answers49
viewsMy array is not returning, if you do not select a previous value
Guys, I’m doing a "lot your pc" and there are some things that are optional and if you do not select a previous one, it does not bring me the value of the remaining. Example: Cabinet Motherboard…
-
2
votes1
answer173
viewsHow to play a var inside Return?
function tamanhoNomeCompleto(a,b){ var tNC = a.length + " ".length + b.length; return tNC; } tamanhoNomeCompleto("Paulo","Paulada"); How do I put the tNC in the return? 'Cause I’m getting this:…
-
2
votes0
answers49
viewsProblems returning an Arduine array
I’m not getting back the array of the following code: void loop() { if(tem_msg){ lcd.clear(); // <-- limpa o cursor e retorna ele pra linha 1 e coluna 1 lcd.print(msg[indice]); // <-- printa a…
-
2
votes2
answers3402
viewsError: Not all code paths return a value
Follow the error: "Logincliente(string, string)":not all source paths return a value class Conta { #region atributos public String nomeCliente { get; set; } public String numAgencia { get; set; }…
-
2
votes2
answers606
viewsEmpty function return
Could someone tell me why my insert2 function is returning null after insertion? she should be returning the string with the success message. <?php require_once 'conexao.php'; $con = new…