Return error code after first detected error

I have a function which does some initialization and calls other functions, each of which returns an error code. I want to be able to return from this function after the first detected error like this: int error_code = FirstFunction(); if (error_cod...
more »

2017-12-03 20:12 (6) Answers

Python tuple unpacking in return statement

The Python language (especially 3.x) allows very general unpacking of iterables, a simple example of which is a, *rest = 1, 2, 3 Over the years, this unpacking has been gradually generalized (see e.g. PEP 3132 and PEP 448), allowing it to be used ...
more »

2017-11-13 20:11 (1) Answers

How to return Response with message, jax rs

I have a web service rest using jax-rs, my service return a List of objects but y don't know how to add custom status values to response, for example the result that I want to build is the following: If its ok: { "status": "success", "message...
more »

2017-09-13 16:09 (2) Answers

Dart - function return multiple values

Is there a way to return several values in a function return statement (otherwise than returning an object) like we could do in Go (or some other languages) For example let's take a basic example In Go, we do func vals() (int, int) { return 3...
more »

2017-07-26 13:07 (1) Answers

Get the return value of date diff?

So i have this query using DATEDIFF function on MS SQL Server? SELECT DATEDIFF(DAY,(select StartDate from CarOrder where OrderID= 59),(select EndDate from CarOrder where OrderID= 59)) This work fine and the result is 10 but i dont know how to get ...
more »

2017-06-25 17:06 (2) Answers

Linux,c++, negative exit codes, clarifiction?

In Linux, c++ can we return exit codes? i.e is this code valid: int main() { return -1; } The reason I am asking if this code is compiled and executed from bash/zsh, the return value would be 255, I thin this due to the fact that its using an 8 ...
more »

2017-05-28 15:05 (2) Answers

Retrieve nested object by key

What would be the most efficient way (with performance in mind, assuming object may be large) to retrieve a nested object by it's key (itemID) within the following object? Obviously, I can access the object by first referencing each of the parents (...
more »

2017-04-28 22:04 (3) Answers

Find one line and get the next lines

With this code I get the full line which includes Name. But I need to get this line AND the next 2 lines. I have no clue how I can do this. def daten(s): for i in s: if i.find('Name') >= 1: daten = i return dat...
more »

2017-02-21 16:02 (3) Answers

Return value of a function in C

I tried writing some code to check if the paranthesis in an expression are balances using the below function. Can someone help me understand why the below function is returning 1 in case of a balanced expression when it's not specified anywhere to re...
more »

2016-12-18 10:12 (3) Answers

Why am I getting a segfault when I `ret'? (FASM)

Through some manipulation I have narrowed it down to a problem with the ret op. I know call pushes the return address to the stack; is it illegal to pop it and push it back? format ELF64 executable 3 entry start segment readable executable start:...
more »

2016-10-09 22:10 (1) Answers

Return Array in C?

I cant return array in c,i am quite new to C so i probably do some kind of funny mistake, here is the code: #define MAXSIZE 100 int recievedNumbers[MAXSIZE]; void setup() { // put your setup code here, to run once: Serial.begin(9600); } voi...
more »

2016-09-23 19:09 (4) Answers

How use return between methods

In my Program I have a button click, from that onclick event I am calling one method for some textbox validation. The code is: protected void btnupdate_Click(object sender, EventArgs e) { CheckValidation(); //Some other Code } publ...
more »

2016-09-20 09:09 (5) Answers

How to return 2 or 3 values with Tuple?

So I'm making a silly game in c# but I'm a bit stuck here. I'm trying to return either 2 values or either 3 values, depends on the rules of the game. I need to know how I can return different amounts of values in only one function. Like sometimes I...
more »

2016-08-19 14:08 (2) Answers

Return in the method overloading

I'm new to Java and I'm learning it myself. I met a trouble when I try the method overloading. This is the code public static void main(String[] args) { calculateScore(); calculateScore(500); calculateScore("Duy", 600); ...
more »

2016-07-09 18:07 (3) Answers

Laravel 5.2 return no response as JSON

If i try to return a JSON-String by using return response()->json($categorie); i get an empty response. If i replace the return for echo, so i will get HTTP/1.0 200 OK Cache-Control: no-cache Content-Type: application/json {"id":5,"name":"blah","...
more »

2016-06-30 13:06 (2) Answers

MySQL - select count returns true

I am trying to determine whether an email is aready in my database or not. For this purpose I write this piece of code: $query_checkmail = "SELECT COUNT(*) FROM user WHERE email = ?;"; if($stmt = mysqli_prepare($connection, $query_checkmail)) { ...
more »

2016-06-19 22:06 (4) Answers