11,649 questions
Advice
1
vote
9
replies
206
views
Cumulative return value in C?
Currently following CS50 and learning recursion in C.
This program returns the number of steps taken to get from n to 1, using the Collatz conjecture. I understand most of what's going on here, except ...
2
votes
2
answers
169
views
How to simplify checking whether a reference variable is null?
I wrote a method that returns a reference to a variable (ref return), and sometimes the returned reference can be null. After calling this method I have to check if the reference is null, and I am ...
Advice
0
votes
4
replies
121
views
Does the finally block run when returning inside try, and what happens if finally also returns?
I have a question about how try/finally behaves when using return statements in C#.
Consider the following methods:
public int Test()
{
return 12;
}
public int Test2()
{
try
{
...
Advice
0
votes
1
replies
66
views
If an expression in a return modifies an earlier result parameter, does the Go language spec guarantee the new value will be returned?
For example, does the Go language spec guarantee the following will print true?
https://go.dev/play/p/Rybua4uBb87
package main
import "fmt"
func main() {
fmt.Println(...
1
vote
1
answer
73
views
Button to save edit in its current model and then return you to previous Details view of a different model
I am using ASP.NET MVC. I have a PIF controller and on the details view, I have data showing from a variety of other models, one of which is called SAEs (I will use this as the example). For each of ...
1
vote
1
answer
145
views
I can't get an optional with (cond) ? value : nullopt ... what should I write instead?
Suppose I'm implementing the function returning an std::optional<T>. In that function, I compute some condition, and then want to return either a value, or a nullopt. I can do it like so:
std::...
0
votes
0
answers
73
views
GDB set breakpoint *exit* of a function [duplicate]
With GDB I can set a breakpoint when a function is entered using break my_func. Is it possible to set a breakpoint on any return of a function? For example in this function, I'd want a breakpoint on ...
0
votes
0
answers
77
views
'return' outside of function
In my React project, the TaskForm component is showing an error saying that the return is outside the function. Even though I've reviewed and "fixed" it, the same error persists. Can someone ...
0
votes
1
answer
62
views
Alternative for ajax with async true too slow
I have a serious problem with an app.
I have a selection box with types of services and other below with student names. Once selected the service, the students will be filtered to the ones that are ...
-1
votes
1
answer
72
views
user = session.get('user') returns None when i try to access it across some different page
This is my login authentication API.
def login():
if request.method == 'OPTIONS':
return jsonify({'message': 'CORS preflight successful'}), 200
data = request.json
email = data....
-2
votes
2
answers
95
views
How do I call the method from a class that creates other objects? [closed]
I have five classes. My Main class, a form class, two subclasses that extend the form class and a createForm class I am forced to use to create new instances of the subclass.
public class FormenFabrik ...
2
votes
1
answer
118
views
What kind of value do you get when you apply “return” to a value without a constraint?
If you apply return to 'a' you get a value of type m Char, belonging to the Monad class: :t return 'a' → return 'a' :: Monad m => m Char. If you apply the resulting value to some other value, say, ...
-5
votes
1
answer
104
views
Returning strings and floats in python functions [closed]
I need to make a function that returns a sentence with variables in it. But how do I exclude all the special string characters that I don't need? (e.g. ( or , or ')
ef area_of_triangle( bottom, height ...
-4
votes
1
answer
117
views
Why isn't the value to be returned from my function returning to main for the subsequent functions?
It's a simple if greater than, then make it the value of BigHigh/BigLow, however it does not return successfully to main for the printout of the respective data. Instead, the printout reads 0 for both ...
0
votes
1
answer
73
views
Modbus.Net TcpClient fails exactly every 6th poll
I implemented a Modbus.Net v1.4.3 client and poll data peridoically in a main program and experience strange behaviour.
Every 6th poll gives:
Data = null
Success = false
ErrorCode = 0
ErrorMsg ...
0
votes
1
answer
41
views
How do I setup a function call to end a hotkey?
I want to use breakout(var) instead of typing that if statement a million times. How do I make that work? Return returns from the function but I want to end the hotkey.
f::{
send "a"
...
0
votes
0
answers
71
views
Problem filtering products using comparison and logical operators in JavaScript
As I filter products from an API using JavaScript's filter() method, I cannot obtain the desired range of products defined by price checkboxes in HTML. The filering works when using an if statement ...
-1
votes
1
answer
57
views
playing around discord.py and ended up in the first problem i cant solve on my own
well, i've been trying to make my first discord bot and i watched this
video to help me do a logging script that shows in the terminal, but the responses.py the guy did in the video made the bot ...
-1
votes
1
answer
74
views
Reset tabs to default resize window .. Javascript
I have that code .. its normal tabs javascript
I need when i resize the window .. To bigest then > 450px tabs back to default i mean tab2 automatic back to tab1 .. Cuz i use it in my menu
I tried ...
0
votes
1
answer
119
views
Using Python in Excel and trying to insert value from Python into cell
The question from PythonProgramming came closest to my question but the answer was unsatisfactory. There is very little documentation on Python-In-Excel. I am running a Python script INSIDE Excel ...
0
votes
0
answers
35
views
How to allocate a pointer of functions that returns a pointer to array of n elements on C++ 20
C++ 20
I have this function:
int (*funcArrayReturn())[6];
The function returns a pointer to an array int[6] (6 elements aggregated).
And I need a pointer of pointers of n elements(in this case 3) ...
0
votes
1
answer
53
views
vb.net Invoke not returning proper values?
I'm interacting with GUI controls from a separate thread when invoked i'm always getting a "nothing" object despite what I think is the right code? Not sure where it's breaking. the second ...
-1
votes
2
answers
258
views
Understanding console.log() within functions vs. using return in JavaScript?
I'm learning about functions in JavaScript and I'm confused about the role of console.log() and return.
function reusableFunction() {
console.log("Hi World");
}
reusableFunction();
I ...
0
votes
0
answers
106
views
ValueError: not enough values to unpack (expected 3, got 2) when extracting data using zip() in Pandas
I'm trying to clean and organize my data from a CSV file using Python and Pandas. Specifically, I want to extract structured information (like Social Security Numbers, Date of Birth, and Relationships)...
-1
votes
4
answers
158
views
NameError: variable not defiend even though its defiend [duplicate]
The first code block outputs:
"NameError: name 'timefloat' is not defined"
while the other works as intended. Why is that?
Code Block 1: raises ERROR
def main():
time = input("...
0
votes
2
answers
57
views
suspend function returning too early
I have the below function which is completing 2 tasks asynchronously to upload data to Firebase Firestore. The 2nd function is returning the documentId of the new document created in Firestore and ...
1
vote
4
answers
204
views
Why is there no "returnif <expr>" that could replace (and optimize) the pattern "return <expr> if <expr>" [closed]
I often find myself typing this pattern for a variety of reasons:
return <expr> if <expr>
Not only does this seem wasteful, but if <expr> has any sort of evaluation time, then it ...
0
votes
2
answers
69
views
Dafny loop with a return in it
How do I prove the following Dafny program?
method return_loop() returns (r:int)
ensures r == 5
{
var i := 0;
while i < 10
invariant 0<= i <= 10
{
if i == 5{
return i;
...
1
vote
1
answer
49
views
Whenever I use deposit method and then check balance method the balance doesnt update any fixes please?
balance = 0
def display_menu():
balance = 0
choice = ' '
if choice == ' ':
print('1.Check Balance \n2.Deposit \n3.Withdraw \n4.Exit')
choice = int(input('Please make a ...
2
votes
2
answers
134
views
Recursion - Not Returning Values as Expected
I'm currently writing a program to return all additions to a number subtracted from itself (For example, if 3 were the number, the output should be 6 (3+2+1). Essentially, I'm trying to have the ...
-3
votes
1
answer
58
views
Getting a return value of None when it works in all other situations in a function with parameters, variables, lists, etc [duplicate]
# Sample Code
import datetime
sample = {
"Eat": [
datetime.datetime(2024, 9, 13, 2, 0),
datetime.datetime(2024, 9, 13, 3, 0),
"2024-09-13 20:43:35.440898&...
0
votes
0
answers
190
views
how to execute both return and redirect on next js api response
I'm working on a Next.js project where I want to redirect the user after a successful login, but also return the user data for further processing. Here’s my code:
if (response.data.user) {
...
0
votes
1
answer
37
views
Comparing a selection
Hi please can you help.
I'm trying to select the last 200 rows in my database, then compare 2 fields in each row, and return each whole row where there is only 1 instance. So, all rows that have more ...
2
votes
1
answer
180
views
If there is [[noreturn]], then why there is no [[always_return]]?
If there is [[noreturn]] (C2X, n3301), then why there is no [[always_return]]?
The semantics of [[always_return]] may be the following:
A function declared with an [[always_return]] attribute shall ...
0
votes
0
answers
259
views
In Wordpress is it necessary to use return; after wp_send_json_error?
After having looked around a bit and not having understood anything I still have the question whether it is necessary to use
return;
after a wp_send_json_error(); I read that the wp_send_json_error ...
-1
votes
2
answers
73
views
In a recursive Python function, why does it matter what parameters are returned?
I thought I understood recursive functions but realised I don't actually understand what is happening under the bonnet
Running this Python code to generate a triangular series gives the expected ...
1
vote
1
answer
104
views
Why it has to have a default return value when implementing binary insertion using recursion?
The searchInsert function return the index where the target should be based on the value. Why it should have the line
return -1;
in the following code? I thought I included all the possible outcomes ...
0
votes
0
answers
28
views
Returning None not breaking out of function
@staticmethod
def log_in():
logged_in = False
while not logged_in:
username = input("Username: ")
if not(User.user_exists(username)):
...
0
votes
0
answers
20
views
Why return false and not simply return is giving the expected behaviour?
My goal is to limit the length of an input of type number to just one number. For this I used the response of Vikasdeep Singh in this SO answer which in my case is working perfectly. I also had to ...
1
vote
2
answers
141
views
What variables are destroyed when calling exit(), based on Microsoft's docs?
I was trying to figure out the differences between terminate(), exit() and abort(), and Microsoft's
C++ program termination documentation came up in my Google search that compares exit vs abort vs ...
0
votes
1
answer
102
views
Return from recursion
Hello in my program I need to implement a recursive descent and return from recursive calls. Input data (100, 37). I was able to print the recursive descent, but I do not understand how to print the ...
-1
votes
1
answer
126
views
When using a function to add a new node to a linked list, why do i need to return the new node? [duplicate]
Currently I am trying to create a linked list.
Here is the class I am using to create nodes:
class node{
public:
int item;
node* ptr_next;
node(int new_item = 0, node* ...
1
vote
1
answer
250
views
z80 assembler ret z; and a; ret
I have the following Z80 asm code (from pokemon legacy crystal)
CheckOnWater::
ld a, [wPlayerStandingTile]
call GetTileCollision
sub WATER_TILE
ret z
and a
ret
i was wondering ...
-5
votes
1
answer
102
views
Calculating the volume of a square
package Pyramid;
import java.util.Scanner;
public class SquareVolume {
public static void main(String[] args) {
double length = 0;
double width = 0;
double height = 0;
...
0
votes
3
answers
91
views
difficulty to understand the code, and maybe the concept itself (recursion problem)
this code below is from Grokking Algorithms book that is an exercise for the functional programming/recursion and an application for the D&C concept. the function finds the maximum number in a ...
-5
votes
1
answer
69
views
Function returning "None" [duplicate]
I wrote the short program below while practising how to use a custom function.
def square(num):
square==(num**2)
print(square(10))
return
I was expecting that when I call the function:
...
0
votes
2
answers
74
views
Return statement isnt working and is giving an error in react js [closed]
I was writing this code where I am making some Modals so I wrote this code
import { useContext } from "react"
import { ModalContext } from "../ModalProvider"
import { ...
0
votes
1
answer
53
views
Store result of json request in a variable [duplicate]
I need to store a value of json response to use in another function.
I have this code:
const url_moodle = "https://xxxxx/xxxxx/app/appmoodlejson.php";
var moodleEmail = function (email){
$...
0
votes
0
answers
27
views
How can I pass a variable to my other function in flask backend?
I am currently building a vocabulary trainer for my assignment. I'm using flask and javascript in the backend.
One function retrieves the vocabulary ID primary key from the database, and I need it in ...
0
votes
0
answers
50
views
Why is it ok to return a reference to a function's default argument? [duplicate]
#include <iostream>
//class for testing**
class T
{
public:
void print() { std::cout << "hello\n"; }
~T() { std::cout << "~T\n";}
};
//function for ...