All Questions

504
votes
19answers
252204 views

What should main() return in C and C++?

What is the correct (most efficient) way to define the main() function in C and C++ — int main() or void main() — and why? If int main() then return 1 or return 0? There are numerous duplicate...
286
votes
9answers
51427 views

How can I index a MATLAB array returned by a function without first assigning it to a local variable?

For example, if I want to read the middle value from magic(5), I can do so like this: M = magic(5); value = M(3,3); to get value == 13. I'd like to be able to do something like one of these: value...
147
votes
14answers
159234 views

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(EXT...
669
votes
13answers
730918 views

How do you return multiple values in Python?

The canonical way to return multiple values in languages that support it is often tupling. Option: Using a tuple Consider this trivial example: def f(x): y0 = x + 1 y1 = x * 3 y2 = y0 ** y3 ...
429
votes
19answers
441361 views

How do I make the method return type generic?

Consider this example (typical in OOP books): I have an Animal class, where each Animal can have many friends. And subclasses like Dog, Duck, Mouse etc which add specific behavior like bark(), quac...
52
votes
8answers
157751 views

Calling stored procedure with return value

I am trying to call a stored procedure from my C# windows application. The stored procedure is running on a local instance of SQL Server 2008. I am able to call the stored procedure but I am not able ...
43
votes
5answers
41791 views

Go: multiple value in single-value context

Due to error handling in Go, I often end up with multiple values functions. So far, the way I have managed this has been very messy and I am looking for best practices to write cleaner code. Let's sa...
165
votes
12answers
162463 views

How to assign from a function which returns more than one value?

Still trying to get into the R logic... what is the "best" way to unpack (on LHS) the results from a function returning multiple values? I can't do this apparently: R> functionReturningTwoValues...
120
votes
14answers
312978 views

How to return 2 values from a Java method?

I am trying to return 2 values from a Java method but I get these errors. Here is my code: // Method code public static int something(){ int number1 = 1; int number2 = 2; return number1,...
21
votes
3answers
64850 views

Return value from SQL Server Insert command using c#

Using C# in Visual Studio, I'm inserting a row into a table like this: INSERT INTO foo (column_name) VALUES ('bar') I want to do something like this, but I don't know the correct syntax: INSERT IN...

Previous Next