return-value

Returning Multiple Values from a Function

Hey, so I'm making an iPhone app and in there is a common function that needs to be called. So I put it in it's own file and set it up, passing the parameters to that and all that. However, I'm not sure how best to return the values from the function. I read up trying to return the values in an array, but I'm not sure how to do it. i...

Which one is preferred, return const double& OR return double.

Given the following scenario, which one of the following is preferred. m_state is a member rater than a local variable. class C { private: double m_state; public: double state() const { return m_state; } // returns double double& state() { return m_state; } } =========================================== class C { private: ...

C# DataSet - Retrieving Unique Value based on column

Hello there, I'm having some issues trying to retrieve unique values from a DataSet in csharp, is that possible? Actually I'm doing something like this that gets a dataset from a webservice: webService.getInstructions(Username, Password, AppKey).Tables[0].Select(null, "account name asc"); So in this case I get a alphabetical list f...

Returning multiple values from a method in Objective-C

I asked a similar question, but I couldn't get it working exactly. I'm building an iPhone app, and there is a method that I want called from different files. I figured the easiest way would simply be to make a method in another file, and call the method from the other files. Here are some problems. I need to return multiple values from ...

C return and comparation inline

Hi everyone, I'm just to figure out what does this method do, I know there must be a way to put this line by line, can you help me please? Thanks int conditional ( int n, EXPRESSION * * o ) { return (evaluateExpression( *o++ )? evaluateExpression( *o ) : evaluateExpression( *++o ) ); } UPDATE: This is the evaluateExpression Code ...

How To Pass a Dictionary To a Function

Alright, so I think I'm doing this the right way. I'm new to objective-C, so I'm not sure about the syntax... I have a set of code that I need to call multiple times, from different files. So I made a new class that has a method in it that I'll call and pass it the values that it needs. Because I am passing different values I've put ...

When returning a pointer, what to return if it's not found? C++

I'm not sure what to return as a default? myDrugs is a private vector<Drug*> container Drug* DrugDealer::getFirstDrugInSack(DrugType drugtobuy) { for (int i = 0; i < myDrugs.size(); i++) { if (myDrugs[i]->getType() == drugtobuy) return myDrugs[i]; } return 0; // is this right? } So I would call it like: D...

Passing return value of a function as an argument

What are some ways of passing the return value of one function as an argument to another? What are some examples in programming languages that you favor, JS, Python, etc? ...

Check if PHP function returns null or nothing

I have this code $return = $ep->$method($params); if ($return === null) { throw new Exception('Endpoint has no return value'); } return $return; Is there any way to distinguish between a method that returns null and a method that does not return anything? ...

How to pass by items by value from an array to a variable in Javascript

Hi, I'm trying to loop through an array "fSel.sI", and based on the data inside, pass them as values (not reference) on to a number of function declarations. Right now the problem is that mydrag contains a reference, and as draggable gets called it uses the last array item data. Hence when start: drag: stop: is called, the values are no...

[C] Why return a negative errno? (e.g. return -EIO)

Another simple example: if (wpa_s->mlme.ssid_len == 0) return -EINVAL; Why the unary minus? Is this (usually) done for functions that return >0 on success and <(=)0 on failure, or is there some other reason? ...

Sort Ascending or Descending inside a Bubble-Sort

After this was answered I continued to work my way through the code. It work's perfect this way: static String[][] bubbleSort(String customerdata[][], int sortafter, int asc) { String temp []; boolean sort; do{ sortiert = true; for (int i = 0 ; i < customerdata.length - 1; i++){ if(customerdata[i][sortafter].compa...

Variable scope js - return initial assignment instead of changed

Have next script: function clicker(){ var linkId = "[id*=" + "link]"; var butnId='initial'; $j(linkId).click(function(){ var postfix = $j(this).attr('id').substr(4); butnId = '#' + 'butn' + postfix; }); return butnId; } Function output is 'initial' value. How to return actual value of variable butnId,after it...

Android ACTION_IMAGE_CAPTURE Intent

We are trying to use the native camera app to let the user take a new picture. It works just fine if we leave out the EXTRA_OUTPUT extra and returns the small Bitmap image. However, if we putExtra(EXTRA_OUTPUT,...) on the intent before starting it, everything works until you try to hit the "Ok" button in the camera app. The "Ok" button j...

Testing for a non-null pointer, and returning null otherwise

I'm wondering whether it's considered okay to do something like this. if ( p_Pointer != NULL ) { return p_Pointer; } else { return NULL; } Without the else, whatever. The point is that if the pointer is null, NULL is going to be returned, so it would seem pointless wasting a step on this. However, it seems useful for debugging pur...

Don't give away your internals? [C++]

Hi, I am reading book called "C++ coding standard" By Herb Sutter, Andrei Alexandrescu and in chapter 42 of this book is an example:(chapter is short so I'm taking the liberty and pasting part of it) Consider: class Socket { public: // … constructor that opens handle_, destructor that closes handle_, etc. … int GetHandle() cons...

jQuery Filter Help

What is wrong with this code... var objects = $(".validated").filter(function(){ return $(this).attr("name") == 'name'; }).filter(function (){ return $(this).val() == ''; }); Its really bugging me :( ...

Java: Return class (Not an instance)

Hi, Is it possible to return in a static method a class? I will explain... I have: public class A { public static void blah(){} } public class B { } I want to create a static method in B witch returns A. So you can do: A.blah(); And B.getA().blah(); This, without creating an instance of A. Just use it static methods. Is this ...

Getting the Return Value from JDBC MSSQL

I'm connecting to SQL Server (2005) through Java using the Microsoft SQL Server JDBC Driver 2.0. How do I get the return value from a stored procedure? I'm doing something like: Connection connection = dataSource.getConnection() CallableStatement proc = connection.prepareCall("{ call dbo.mySproc() }"); proc.execute(); Should I be us...

Return more than a single value from a WebService

I have to return a lot of values back to my windows application from my webService. But how would I return more than just a single string/int/boolean from my WebService to my Application. How would I return a collection, keyValuePair, or even better, a DataSet? Or is this just imposible? thank you :) ...