Questions tagged [return]

A return statement causes execution to leave the current subroutine and resume at the point in the code immediately after where the subroutine was called, known as its return address. The return address is saved, usually on the process's call stack, as part of the operation of making the subroutine call. Some programming languages allow a function to specify one or more return values to be passed back to the code that called the function.

Filter by
Sorted by
Tagged with
0 votes
1 answer
24 views

Struggle disposing of JDialog

I tried to create a little JDialog as a popup for requesting two values from the user: width and height. After a lot of tweaking, I thought I might retrieve those values upon the disposal of the ...
Das heilige Dönerhuhn's user avatar
-2 votes
0 answers
42 views

Create a function inside of another function, then return created function to global scope [closed]

I'm running this function fillRestOfData (which is inside of another function) that creates a function inside called triggerFetch const fillRestOfData = (newestResponseSetDOM) => { const ...
Eric Garcia's user avatar
0 votes
0 answers
5 views

a function that returns the sum() of ord() list, but when called in the main function returns the list element instead of the sum()

[[enter image de import argparse import os.path import re from functools import reduce def get_args(): parser = argparse.ArgumentParser(description='word coder', formatter_class=argparse....
Younes Abuelayyan's user avatar
-3 votes
0 answers
36 views

How does the return statement work in this task (Java) [closed]

So i did this one of many task in java without help, unfortunately at some point i got confused with so many return statements so i just tried my luck with replacing the return statement in line 11. ...
L9 Snus's user avatar
0 votes
0 answers
14 views

Which is the better way to return multiple DataTable in C#

I need to call a method to return three datatable Method1 public DataTable[] ReturnMultipleTable(string query) { DataTable table1 = new DataTable(); DataTable table2 = new DataTable(); ...
Potato's user avatar
  • 1
-2 votes
0 answers
88 views

PHP $_POST gets populated asynchronously [closed]

I need to call a .php file using an ajax request. However, I do not end up having the expected variable values, as explained below. Debugging this is limited by the fact that echoing the problematic ...
D_00's user avatar
  • 1,457
-2 votes
0 answers
45 views

Program not returning the result despite running through the lines [closed]

I wrote this solution for the leetcode question https://leetcode.com/problems/search-in-rotated-sorted-array/ What i m perplexed about is that despite entering the first and the third if statement, my ...
Shaksham Shubham's user avatar
0 votes
0 answers
4 views

When creating a view it is taking me to the index view and not the created view

When creating a view inASP.NET MVC, I am creating a view in the homecontroller, but when i run that view it takes me to the default index view. public IActionResult AdoptPet() { return ...
Asad Patel's user avatar
0 votes
1 answer
34 views

Return string from a void method that contains winappdriver

I'm trying to create a code with loops from some strings to get a text and I need to "return" the string I get in the else if(select == "t")... how can I do it?? Part of the code ...
Alexandre's user avatar
-2 votes
0 answers
47 views

Bool Function always returning true even after return "false" [closed]

I am solving this question on leetcode and my code is always returning true even if the false condition is satisfied for input [3,2,1,0,4] class Solution { public: bool canJump(vector<int>&...
Ajay Sehrawat's user avatar
0 votes
2 answers
63 views

Why does 'total' not exist in the current context?

I am trying to print n to the power of p without using Math.Pow(). Here is the pseudocode: get two integers n , p from the user using a for-loop calculate the power function n ** p without using Math....
Hash Slinging Slasher's user avatar
-4 votes
0 answers
37 views

Program must immediately stop once the username/password is wrong [closed]

I want it to stop when the user entered a wrong username. It stops there and doesn't ask about the password. import java.util.Scanner; public class mavenProject9 { public static void main(String[]...
CLaD's user avatar
  • 1
-3 votes
1 answer
45 views

Reasons to have a return statement without returning any value [closed]

The following code came from the book Fundamentals of Python, which made me think there must be some reasons for the author to use return without returning anything. def save(self, fileName = None): ...
Nemo's user avatar
  • 1,099
-1 votes
2 answers
35 views

Function to read file passing it by parameter

Hi guys I'm having difficulty with a method to read file.I have not found anything in the documentation. I'm trying to return an array of char. public class ReadFile { public static void main(...
Maiinjoon's user avatar
-3 votes
0 answers
19 views

Woocommerce empty cart page "browse store" button link not pointing to the right store url

I'm creating an e-commerce website using wordpress and woocommerce. In my Woocommerce shop cart, when there is no item placed, the page displays the text message "your cart is currently empty...&...
Samuel Chiang's user avatar
0 votes
1 answer
17 views

I get the Error CS0177 (The output parameter...must be assigned to before control...).Althoug looked to similar entries couldn't fix it

With the code below I am reading process variables from a PLC controller. The method has outputs like var_result and var_result_float. I get the Error CS0177 in the last line regarding that these ...
Mdarende's user avatar
  • 451
0 votes
1 answer
19 views

How to use GDB to check where a function calls return?

I have a function called test_linked_list() that tests a data structure using a series of if statements. If a test fails it calls return 0. // ie. test_linked_list() { if(!insert_end(l,10)) ...
Icelightz's user avatar
-2 votes
0 answers
25 views

Figuring out input for a math functions [duplicate]

In this problem you must create functions to solve each criteria. The first criteria is to solve the area of a circle. The function will have the parameter of radius and the function will calculate ...
Cuttino Jones's user avatar
0 votes
0 answers
25 views

How to write array in Return *function to main function? Or Is that possible? [duplicate]

I'm studying on c and i wrote 2 array in main function. After compare them and sum their values in with in each array members. After find which one big than other and i printed which one is. It's okey ...
SC K's user avatar
  • 1
3 votes
5 answers
96 views

How to exit function early if outputs are not requested?

I'm writing a function that has multiple inputs and outputs. All the outputs are only needed on infrequent occasions. Moreover, some inputs are only used to generate some of the infrequent outputs. A ...
magnesium's user avatar
  • 334
2 votes
2 answers
74 views

Pointer to member of returned struct, is it safe?

for example: struct A { char s[10]; } f() { struct A ret; scanf("%9s", ret.s); return ret; } int main() { char *str = f().s; puts(str); } is str pointing to a ...
Abdulmalek Almkainzi's user avatar
1 vote
2 answers
52 views

print within function gives correct value, but the return gives zero?

I've been trying to return the "hypo" and I can get the correct value to print within the function but when I try to use the return value of hypo outside of the function it is returning zero....
PapaPumpkin's user avatar
0 votes
1 answer
51 views

C++ settings return value mutex

In my application running on an ESP32 using FreeRTOS, I've implemented a setting class responsible for storing various settings. I'm currently concerned about the thread safety of this class, ...
Bas Visscher's user avatar
-3 votes
1 answer
23 views

Write a function named WeekDay() making use of select case, the function will receive a single argument containing a STRING (days Monday - Sunday)

Use Scilab answer the following questions: Paste both your function code, and console output demonstrating the features of the function. Write a function named WeekDay() making use of select case, the ...
Priyanka Gosai's user avatar
0 votes
0 answers
35 views

for loop returns only elements where i = 1 [duplicate]

I'm trying to return 3 divs (for now) with a for loop but I'm only getting the first one, could someone explain why doesn't this work and how to fix it. This is my function const Bracket = ({bracket}: ...
Maksymilian Mikolajczak's user avatar
1 vote
3 answers
123 views

Test return value and return

This may be a silly question, but I am working if there is a concise way to test the return result of a function, and, if it fails to meet a condition, return that value (i.e., pass it on). To address ...
Patrick Wright's user avatar
-1 votes
2 answers
43 views

what is the nature of return in python functions [duplicate]

def fact(n): if n == 0: return 2 return n*fact(n-1) print(fact(5)) I have this code of python function which find the factorial of a given number "n" but I am curious about ...
Abdul Basit's user avatar
-1 votes
1 answer
59 views

Python: Why does returning a string change it to a list (of length one)

I'm creating a string in a method and returning it. But I get back a list in stead of a string. def method(): string1 = "hallo1 \nhallo2" print("string1 :") print(type(...
Polbeer91's user avatar
0 votes
1 answer
18 views

Error : Expected to return a value at the end of arrow function

Expected to return a value at the end of arrow function , this is a common problem one can face easily while using react JSX in strict mode contentType = id => { console.log('') if (id === '...
Avik Biswas's user avatar
1 vote
1 answer
30 views

React, display a customized array in the return of the main function

I have a react project with the home.jsx file where I create an array of JSON: function Home() { const posts = [ { id:1, title:"Point Break", year:"1992", ...
Andy McRae's user avatar
1 vote
2 answers
28 views

no function definition: RETURN

I want to use keyword "return" to return value for a function but I got a runtime error I can only successfully return value as below. However, the function will not "end directly"...
Wu Yuan Chun's user avatar
  • 1,136
-2 votes
2 answers
56 views

Write a function to compute the product, e.g

Factorial of n is the product of the numbers from 1 to n. factorial(1) → 1 factorial(4) → 24 factorial(13) → 6227020800 It must include: functions & arguments, return statement, use a loop My try:...
siirlan's user avatar
-1 votes
1 answer
42 views

Menu driven Program not functioning

I am trying to create a Menu Driven program in C but I unable to get back to menu after completing one function. How do I program it so that the program ask the user to continue or not after each ...
Harshal Malani's user avatar
1 vote
1 answer
102 views

Why does Rust require return for early returns, but not at the end? [closed]

Why are implicit returns at the end allowed, but early returns require the return keyword? fn bar() -> u64 { if true { 1 } else { 0 } } This is is semantically equivalent but raises an ...
Banana's user avatar
  • 2,305
1 vote
3 answers
89 views

How to return a string in Clojure

I'm very new to Clojure and functional programming. I am working on Codewars "Even or Odd" practice question. My desired result is to return "Even" or "Odd" given the ...
Dusty Shaw's user avatar
-1 votes
1 answer
34 views

In my C# code I get compiler error CS0029 when I try to define the return of my IEnumerable Task. How can I correct it?

In my following C# code I get compiling error when defining the return of my IEnumerable Task (last line of my code) Compiler Error Error CS0029 Cannot implicitly convert type 'void' to 'System....
Mdarende's user avatar
  • 451
-1 votes
2 answers
41 views

Return statement inside if statement ignores variable it should return [duplicate]

I have a little calculator app. The return statement is inside of an if statement checking for a variable to be equal to "null". If the variable is equal to "null", it should ...
Wanzie's user avatar
  • 1
-1 votes
1 answer
60 views

i can't exit while loop without using exit(). Neither break nor return don't exit the loop?

machine = True money = 0 def game(): global money, machine while machine: order = input("What would you like? (espresso/latte/cappuccino) ") # Gets order machine = ...
MaximusPrima's user avatar
0 votes
1 answer
30 views

Is there a way to console.log an array using a function containing a for loop?

I'd like to print an array using a function that contains a simple for loop. So far my code will only list the first item in the array. It seems the return value only allows for the function to run ...
cajeck's user avatar
  • 3
0 votes
2 answers
62 views

Question about functions and returns in javascript

I am trying to create a function that converts celcius to fahrenheit and vice versa using a return statement inside. I'm confused why the code below won't return or log anything on the console but the ...
Bruce Ferreira's user avatar
0 votes
0 answers
13 views

Assigning a function to a variable immediately prints echo? PHP

I'm fairly new to PHP, so bear with me, this made me curious. I suppose my question is why does assigning the function to the variable print the echo of the function, and why doesn't it print the echo ...
Dominique K's user avatar
0 votes
0 answers
38 views

Communication between pages in Flutter

My goal is to create a quiz application on flutter that contains different types of questions and answers. For example, we write the answer using textfield on one page and I use answer options on ...
Furkan Balcı's user avatar
-2 votes
5 answers
103 views

how does main function knows the void function is executed successfully in C?

In this simple program in C #include <stdio.h> void hello() { printf("hey i am from void function\n"); } int main() { hello(); return 0; } Output: hey i am from void ...
ASWIN's user avatar
  • 19
0 votes
0 answers
31 views

Exception function does not return int value properly and give None instead [duplicate]

In this code, I wanted to take 2 numbers and add them to the list to use later. This code works correctly as long as it does not get an error, but when one of the exceptions is activated, the function ...
yousof A.A's user avatar
0 votes
1 answer
21 views

Python: Returning every element from a list in a normal-looking way for integer factorization function [duplicate]

I'm a college student practicing some coding before school starts back up and I made a python function that is supposed to give the prime factorization of a number (excluding 1). It references a ...
silly_bear_11's user avatar
-1 votes
2 answers
44 views

Why the 'else' block in function works, meanwhile the 'if' block is True?

def foo(): if 1 > 0: print('Works first condition!') # This is a 'else' block which supposed not to be # executed cause of the above 'if' condition is True, but ...
cardinal2000's user avatar
0 votes
0 answers
27 views

Python to HTMl Output - Return HTML while running SubProcess in background

I am using python to output html. So far is working well however I'm now at a point where I need to run a long python function. Given the method to output the html uses a python return statement. When ...
RickPeck's user avatar
  • 165
2 votes
2 answers
41 views

Is it possible to make return statement dependent on the type of instance in python?

It is hard to formulate a question… I want to create a function that can return for example string OR list. It will return depends on the type of instance this value is assigned to latter. For example,...
Danya K's user avatar
  • 165
0 votes
0 answers
16 views

Recursive & Return in JavaScript [duplicate]

Please somebody help me here, I am facing problem with return and recursive function using together for a long time now; How effectively and clean I can use with my following program and in my ...
paldong's user avatar
1 vote
0 answers
33 views

Non-local returns from constructs that do not have a call stack entry

I'm implementing named non-local returns in an AST interpreter written in Rust, and I have principles for closure NLR laid out. However, I'd like all expressions to support being labeled and returned ...
Princess Nova's user avatar

1
2 3 4 5
233