Menu
  • HOME
  • TAGS

How can I use a non-static (dynamic instance) object as return for a static method in Java? [closed]

java,static,return

Looking at the error you have, your question probably misses a bit of code, it is probably like: public class SomeClass { public class UserData { .... } public static UserData decodeText(String codeString) { UserData data = new UserData(); .... } } Inner Classes So you are using the concept...

Android: How to return huge byte array as activity's result?

android,android-intent,camera,return,onactivityresult

Is it caused by the size of the image? Yes. I checked and found out that it's over 2 million bytes. That is about twice as big as you can return. I need to use my custom camera but I can't return my data. Either: Do not make these...

global variable returns null when sent to list

php,variables,null,return,global

I would check the actual value of $_SESSION['action'], as well as separately echoing out (or var_dump) other variables such as $emp_name for testing / ensuring they are actually populated as you expect. As Jay Blanchard mentioned, using $_SESSION['someVar'] is better than using the global keyword. Found some good info here:...

How can i change action of the button “return” on the keyboard on Xcode?

ios,text,keyboard,return,action

UITextField has this delegate method that you can implement, and get's called when you press return on the keyboard: - (BOOL)textFieldShouldReturn:(UITextField *)textField You can add a new line char "\n" to the textView text and it would go to next line. UITextView it's suppose to work like that where it...

Animated/timed text with JavaScript return

javascript,return

This is how I might do it: var stack = ["blob1", "blob2", "blob3"]; function nextItem() { document.body.innerHTML += stack.shift() + "<br>"; } nextItem(); setTimeout(nextItem, 500); setTimeout(nextItem, 1000); ...

AS3 Custom DialogBox: How to send pushed Buttons label to Main.fla

actionscript-3,class,flash,return

Create a class DialogEvent extends Event. Add private var _choice:String = ""; Add public function get choice():String { return _choice; } to retrieve the value from the object Duplicate the constructor of the Event class, then add a first parameter that takes the chosen value public function DialogEvent (choice:String,.......

Am I oversimplifying returns?

java,arrays,return

If your method has declared to return int it must return int for any case,if you want to loop for all items and check whether array contains '0' or not.If all fails return -1 or throw Exception public int questionsMissed() { for (int index = 0; index < 20; index++)...

How to Supress implicit return from a closure with Void return type in Swift

swift,return,closures,implicit,completion-block

You're having this problem because you are creating an NSDictionary, which is not mutable. You'll need to use an NSMutableDictionary to do this. My code: import Foundation func doSomething (completionHandler: (done: Bool) -> Void ) -> Void { completionHandler(done: true) } doSomething({ (done: Bool) -> Void in var data: NSMutableDictionary...

Best practice for returning in PHP function/method

php,function,methods,return,code-standards

There are people arguing for single exit points in functions (only one return at the end), and others that argue for fail/return early. It's simply a matter of opinion and readability/comprehensibility on a case-by-case basis. There is hardly any objective technical answer. The reality is that it's simply not something...

Python: how to reference values in a def

python,reference,return

You don't you need to return them def example(value1, value2): value1 += 2 value2 += 4 return (value1, value2) >>> value1 = 0 >>> value2 = 0 >>> value1, value2 = example(value1, value2) >>> print(value1, value2) 2 4 You can only do what you are asking if the passed-in type...

Angularjs .factory method return

angularjs,methods,return,factory

If you carefully look at your code for getUniqueIndexIDs you will realize there is a callback. The second return is not a return from getUniqueIndexIDs but from your then's callback function. Essentially your getUniqueIndexIDs returns a promise created by then. This promise is resolved by the return value then callback...

when a method should return a value java

java,eclipse,return

1.) You need to pass the user object. 2.) Also need to return the user object. public static int increase_user(int user) { int number = 3; if (number < 10) user++; return user; } public static void main(String[] args) { int user = 10; user = increase_user(user); System.out.println(user); } Making...

Remote Job execution with non terminating Return

powershell,return,powershell-remoting

You seem to be under the impression that you have to use the return keyword to make a function(?) return something. PowerShell works a little differently, though. PowerShell functions return the entire non-captured output on the success output stream. The return keyword is just for making a function return at...

NGINX - Return vs Rewrite

redirect,nginx,return,rewrite

As stated in the nginx pitfalls you should use server blocks and return statements as they're way faster than evaluating RegEx via location blocks. Since you're forcing the rewrite rule to send a 301 there's no difference when it comes to SEO, btw.. ...

Difference in a way of writing a void function return [duplicate]

c++,return,void

The C++ standard says: A return statement with an expression of type void can be used only in functions with a return type of cv void; the expression is evaluated just before the function returns to its caller. So the two forms are equivalent in C++. Note that the C...

Trying to execute a assembler bytestream as a C native function

c,segmentation-fault,return,memory-address

This can have many reasons. You disabled the stack smashing detector, but that doesn't mean, that ret in main is going to be allocated right after the return address. The compiler and linker have some leeway in aligning the variables' addresses to improve performance or to satisfy CPU alignment requirements....

JAVA adding total

java,return,totals

First of all, Eran solves your original problem. Your problem was that you didnt sum up the amounts, you did: total = total; return total; My suggestion for you is when you have code like this: clientList.getClientList().get(i).getName() make a function in ClientList which gets an integer i and returns the...

What is different between return 1 and return 0? And how backtracking work in given code?

c,function,boolean,return,backtracking

In given example what is different between return 1 and return 0? Judging by the following block code if(solve(a)) { return 1; } it seems that a return value of 0 indicates not solved yet and a return value 1 indicates solved. I us int fun() in place bool...

Return data from async function [duplicate]

javascript,node.js,asynchronous,data,return

For any asyn function you need to have a callback function which gets executed once the operation is complete. You can modify your code like this and try. var diskspace = require('diskspace'); var fs = require('fs'); var aux; function getDiskSpace(cb){ diskspace.check('C',function(err, total, free, status){ var arr = []; var aux=new...

Want to `return` more than once

javascript,three.js,return

You can only return one value. The first call of return ends your function. You cannot solve this by wrapping your return statement in another function, either. Wrap the values you wish to return in an array, this allows you to access all of them in the calling function: var...

Scala: “explicit return” required?

java,scala,boolean,return

The last expression's value is used as the return so: def checkSimple(str1: String, str2: String): Boolean = { if (str1 > str2) { println("str1 > str2") true } else { println("str1 <= str2") false } } will behave the way you expect...

Passing a return from one function to another function that already has set parameters?

node.js,function,return,processing,osc

Alright. So I figured out what to do, at least in this scenario. I'm sure there is a better way to do this, but for now, this works. I'm mapping an existing global array of peripherals into the write function, while passing the OSC message to it as a parameter....

How to return multiple results in a php function

php,function,foreach,return

I recomend you to return an object with each item you want in attributes. To return an object, firstly you need a class: class MyClass { private $artists; private $songtoid; private $artisttoid; public function __construct($arg1, $arg2, $arg3){ $this->artists = $arg1; $this->songtoid = $arg2; $this->artisttoid = $arg3; } public function getArtists(){return...

Can a Python function return only the second of two values?

python,matlab,function,return

The pythonic idiom is just to ignore the first return value by assigning it to _: _, y = function() ...

When returning an object, I can't simply use {} after class name

c++,return

The line return nested{}; employs the new C++11 braced-initialization and value-initializes the object. As you can see here, braced-initialization is not supported in Visual Studio 2012 (VC11), so you get a compile-time error. The only solution is to use return nested(); instead, or update your compiler....

Replacing roman numerals with numbers from file- Python- type error

python,file,return

The problem with replace is that you have to put it in an awkward order to not replace (for example) the I in VI. Consider something like: import re def replace_roman_numerals(m): s = m.group(1) if s == "I.": return("1.") elif s == "II.": return("2.") elif s == "III.": return("3.") elif...

Returning values from nested functions - JavaScript [duplicate]

javascript,google-maps,return,nested-function

You can't do that because of the asynchronous nature of the location API, instead you need to use a callback based approach where the callback function will be invoked once the locaion API returns the value. function getUserPosition(callback) { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition( function (position) { callback(new google.maps.LatLng(position.coords.latitude, position.coords.longitude)); },...

Python: return statement still returns none from function

python,function,return

You need to return it here too def date_initialize(date, date_i): print " initializing date configuration" # Does a bunch of junk return rate_of_return_calc(date_new_i, date_i) ...

Golang, how to return in func FROM another func?

go,return,func

A function or method cannot control the execution (control flow) from where it was called from. You don't even have guarantee it was called from your function, it may be called to initialize a global variable for example. That being said it is the responsibility of the caller to end...

C++ returns objects by value

c++,function,return

Meyers is correct in the main, though you have to take that wording with a pinch of salt when dealing with references. At a certain level of abstraction, here you're passing the reference itself "by value". But what he's really trying to say is that, beyond that, C++ passes by...

Function that calls itself returns only first result of its call

python,return,call

You can use iter with a for loop, you don't need to keep calling the function, iter takes a sentinel value as it's last arg which it will keep looping until the sentinel value is entered: def create_sub_cat(parent): print "creating subcat\n {} > ".format(parent) for conf in iter(lambda: raw_input("type new...

SDL window closes on startup and returns 0

c++,return,sdl,exit

A common error here: if(ev.type = SDL_QUIT) - this is an assignment, not a comparison. The first version of your code should work then....

Return statement for a string array giving strange result

java,arrays,string,return,system.out

but the return statement just dumps out a load of garbage "[Ljava.lang.String;@85bdf6" That's not the return statement, thats what you do with the return value. Most probably you have used System.out.println(teamsToProgress()); instead you should do what you have done in teamsToProgress() already. System.out.println(Arrays.toString(teamsToProgress())); In the first case you print...

Unable to return correct value of a variable in a recursive function

c,function,recursion,return,factorial

Sure. you forgot to return a value at the very the end of recursion(). Without that return statement, the use of recursion() as an argument ot printf() invokes undefined behaviour. To elaborate, only for the case when x == 0 is TRUE, you're using a return statement to return a...

c# Pass a multi-line string to a function and return an array

c#,arrays,string,textbox,return

You need a parameter and return type (string array), you may need to read more about Passing Parameters and return statement for returning values. private string[] Load_Signal_Strength_Array(string signalStrengthInput_450) { string[] SignalStrengthInputArray450 = SignalStrengthInput_450.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); foreach (string a in SignalStrengthInputArray450) { // loads some stuff into the...

c++ function returning template type checking

c++,templates,types,return,token

The problem here is that the compiler needs to know the type of each expression on compile time and you're trying to make a function whose return type is known only on runtime. Instead create a base class for all the types you want to return and return a pointer...

return statement of function is not working as expected

php,function,return

Your fourth function will return the value to the firth function. So you have to return each function call in each function, to then be able to assign the value to the variable, e.g. function fourth_f($var){ $var = $var + 1; return $var; //returns this value to function third_f }...

Can long int be returned by a function in c?

c,function,return

Yes, it is valid. As long as you're retuning a proper long int value (which we can see, you're doing#) and catching that into another long int (you need to take care), it should be fine. #) As per the C11 standard, LONG_MAX is +2147483647 and 1000000000 is less than...

Return a pointer to array from a function in C++?

c++,arrays,function,pointers,return

I'd say the more correct way to write myfunction is: std::vector<double> myfunction(double *x, double *y, int n){ std::vector<double> r; r.reserve(n); for(int i=0;i<n;i++){ r.push_back(x[i]+y[i]); } return r; } That way, you don't have to worry about memory leaks, and your while loop can just be: while (/* some condition*/) { std::vector<double>...

Tcl return vs. last evaluated in proc - internals

return,tcl,proc

In Tcl 8.6 you can inspect the bytecode to see how such procedures compare. If we define a pair of implementations of 'sum' and then examine them using tcl::unsupported::disassemble we can see that using the return statement or not results in the same bytecode. % proc sum_a {lhs rhs} {expr...

Read external file match specific string in first column and return respective string of second column in php

php,string,return,matching,vlookup

I suppouse data have not error, so don't do any test $c1 = file('csvurl.txt'); $l = count($c1); for ($i = 0; $i < $l; $i++) { list($name,$url) = explode(',', $c1[$i]); // making array $red['H001'] => 'URL1" $red[trim($name)] = trim($url); } unset($c1); $c = file('tickerMaster.txt'); $l = count($c); for ($i =...

php return statement in if statement

php,if-statement,return

Your return will work because you are not interested in the result that is being returned. You just want to continue the for-loop. If you had a code construction that tested something and you want to know the result of the testing then you could use return false to let...

Missing return statement error with method that has a return in for loop

java,string,for-loop,return

In answer to your question in the comments. You can only return a single object from a function. You could take another container and populate it with the names and return that. For example, public LinkedList<String> check() { LinkedList<String> names = new LinkedList<String>(); for (Person person: passengers) { names.add( person.getName()...

Tic Tac Toe Game: How to loop it?

c++,loops,return

use a while loop and another function for win (to refactor the code and exit condition). main() { while(1){ //do everything here //when someone wins call someOneWon(name); } } function void someOneWon(string name){ char input; cout << name << " won" << endl; cout << "would you like to play...

Recursive function in PHP function : how to prevent return value?

php,function,recursion,return,return-value

You are not assigning the return value of the recursive call back to $filter_video, change to: if ($total_count > $page_size * $page_number) { $filter_video = get_video_list($page_number, $filter_video); } Or, even better: pass by reference. This eliminates the need for return values altogether, especially useful for recursive functions (notice &$filter_video in...

C++ operator overloading >= with 2 different returns

c++,return,operator-overloading

So if you organize your class differently, perhaps you can do something like the following: class PlayerWeight { private: int weight; public: int getWeight() const { return weight; } bool operator >=( const PlayerWeight &playerWeight ) { return weight >= playerWeight.getWeight(); } PlayerWeight( int weight ) : weight( weight )...

What happens with return value?

c++,pointers,return

The original code won't compile by GCC because the function E T::get() { return this->data; } returns value. When you assign the pointer e2 = &(t.get()); in the block, it makes a temporary copy of data. After you exit from the block, when you reference the pointer e2, it no...

Return type of a constructor in c++

c++,constructor,return,return-type

Does this part of code returns an object of type x by value? Yes, it creates and value-initialises a temporary object of type X (by calling the constructor with the default value of zero) and returns that. can a constructor can return an object? No, that doesn't make any...

What is the difference between these two methods for checking if a number is a prime?

java,return

Both solutions work and both are valid for all the reasons you have already identified. Good analysis. As others have noted, the differences are purely stylistic. Here is an interesting discussion about the single return statement style in java. Performance-wise, I wouldn't expect a significant difference between the 2 approaches....

Java - multiple return statements - first one not returning?

java,android,debugging,return

If the condition in your if statement is true, then return true; gets executed and the method terminates. To check this, just put a println(...) before the return false; instruction, you will see that it won't be executed. Check again your debug, you probably got confused by the tool....

I need to find the longest word in a sentence using JS

javascript,html,count,return

try this: Phrase: <input type="text" id="input1" name="LongestWord" placeholder="Put Phrase Here"> <br> <input type="button" id="btn1" value="get Longest Word"> <br/> Longest Word: <span id='sp1'></span> <script> var btn = document.getElementById("btn1"); var in1 = document.getElementById("input1"); var sp1 = document.getElementById("sp1"); btn.onclick = function(){ var vals = in1.value.split(' '); var val = vals[0]; vals.forEach(function(v){ if(v.length>val.length) val...

How do I return a value from a second function in PHP?

php,function,return,value

Your code is mostly working, you simply misplaced some quotes and concatenation. Adding quotes where they shouldn't be or forgetting to add them where needed will cause PHP to misinterpret your code. You might consider using a code editor or IDE to avoid this in the future. They will highlight...

Why does returning in Interactive Python print to sys.stdout?

python,return,stdout,python-idle

The interactive interpreter will print whatever is returned by the expression you type and execute, as a way to make testing and debugging convenient. >>> 5 5 >>> 42 42 >>> 'hello' 'hello' >>> (lambda : 'hello')() 'hello' >>> def f(): ... print 'this is printed' ... return 'this is...

Returning a pointer which is a locally declared wchar_t

c,static,scope,return

It's OK to return a local variable, it's not OK to return a pointer to a local variable. int foo(void) { int var = 42; return var; //OK } int *bar(void) { int var = 42; return &var; //ERROR } In the case of returning a pointer, all it matters...

inlining when function body has no return statement

c,return,inline

I read that compiler may not perform inlining when "return" statement does not exist in function body This is not at all true. Compiler can certainly inline void functions, but whether it does inline any function is upto it even if you specify inline keyword. Just see here: https://goo.gl/xEg6AK...

Getting an Array from Return statement, deduce a string from that

sql,ruby-on-rails,arrays,ruby,return

return [object1, object2].compact you can use compact method to remove nil value of array....

Syntax error on return

python,return,syntax-error

You are missing a closing parenthesis on the preceding line: result = factorial(n) / (factorial(k)*factorial(n-k) # ^ ^ ^ ^ ^? # 1 2 2 2 21 ...

How would I access this specific part of a JSON?

json,location,return

well.. I guess you should iterate the full JSON content and look for the key "RankedSolo5x5". Once you find it, you will be able to get the values. If you don't know how to iterate a JSON file please take a look at the following link: How do I iterate...

VBA Return Carriage and Fill Code

excel,vba,excel-vba,return,carriage-return

I just added a loop at the end looking for blanks - Sub InString() Dim rColumn As Range 'Set this to the column which needs to be worked through Dim lFirstRow As Long Dim lLastRow As Long Dim lRow As Long 'Difference between first and last row Dim lLFs As...

python functions veusz object

python,function,return

This is a Veusz specific question. When you write graph=page.Add('graph'), Veusz doesn't know the name you gave the variable. Here, the new graph is assigned the default name "graph1". When you're navigating the tree with ".", you have to use the real name of the object in the document. If...

is return main(); a valid syntax?

c,function,return,language-lawyer,return-type

I didn't know that the return statement accepts any parameter that can be evaluated to the expected return data type, Well, a return statement can have an expression. Quoting C11 standard, chapter 6.8.6.4, The return statement. If a return statement with an expression is executed, the value of the...

Return pointer undefined even though it should be

c++,pointers,return,undefined

Your problem is that passing arguments to functions in C++ defaults to being by value. A consequence of this is that changes to the value of an argument are local to the function. So, given your edited code Menu* Content::CreateItem() { Menu* menuPointer = new Menu; //initialize values return menuPointer;...

c++ : stop only last call of recursive function

c++,recursion,return

return only affects the immediate function. If you are returning from a recursive function and all parent calls also end, then it's not return that causes that but your terminal condition in each parent call must also have become true. That is: your functions are terminating because they are all...

Return statement not working python 3

python,return

In python when you create a variable inside of a function, it is only defined within that function. Therefore other functions will not be able to see it. In this case, you will probably want some shared state within an object. Something like: class MyClass: def fun(self): self.variable = input('Enter...

good practises null object return [closed]

c#,object,null,return

In case to signal "failed to create object" C++ class constructs throws exceptions for this purpose. Some languages / projects prefer to use exceptions more to keep happy-pass happier while others may not....

I don't understand function return in javascript

javascript,function,return

Why is it used in a function? 1. To return back the results of the function The return does what is says - it returns back some values to the function caller function addNumbers(number1,number2){ var result = number1+number2; return result; } var result = addNumbers(5,6); //result now holds value...

JavaScript: How do I return two values from a function and call those two variables in another function?

javascript,function,parsing,return

You can't return two values like this: return (num1, num2); Javascript doesn't work that way. If you're trying to do a Python-like tuple, Javascript doesn't have a data structure with that syntax. You can put two values in an array and return the array or two values in an object...

How to return a value of indeterminate type from a switch statement from a method

c#,switch-statement,return,return-value

Dynamic You can use dynamic as a return type: public dynamic GetData() { dynamic data; switch (SomeType) { case SomeType.A: data = (Type_1)SomeType.Data; case SomeType.B: data = (Type_2)SomeType.Data; case SomeType.C: data = (Type_3) SomeType.Data; case SomeType.D: data = (Type_4) SomeType.Data; case SomeType.E: data = (Type_5) SomeType.Data; case SomeType.F: data =...

Assigning (or tieing in) function results back to original data in pandas

python,pandas,return,def

Changing the output of regress to a Series rather than a numpy array will give you a data frame when you groupby. The index of the series will be the column names: In [37]: df = pd.DataFrame( [[ '6/10/2015', '1/19/2016', 'IBM', 50, 42.0], [ '6/10/2015', '1/19/2016', 'IBM', 55, 41.5], [...

python input check function not being called properly

python,return,global-variables,try-catch,raw-input

You define some functions, then call temp_coverter(). This function calls temp_input(otemp), sending it an empty string for no reason that I can see, other than the possibility that you're unaware that you can define a function with no parameters. This function then returns a value, which you don't save. After...

mt_rand() returns unexpected output

php,string,function,return

I tried to simplify your functions a bit: You have to return your values, otherwise your functions will return NULL by default. Also you can access a string like an array, so I used $company[0] to get the first letter of the company, which you then can concatenate with the...

Return various amounts of values in symfony

php,arrays,symfony2,return

Just return this : return $this->render('MainBundle:Default:addtolist.html.twig', array('tablica' => $tablica)); Then you can parse it in Twig to do whatever you want to....

char * disappears if I don't print it?

c,string,return

char SecCode[SECCODELENGTH]; char *SecuCode = (char*)&SecCode; SecCode is a local array to function getSecCode() and you return the address of this local array which will lead to undefined behavior....

Sharing values between methods

python,python-3.x,return,return-value

This should work. Rather than passing variables unnecessarily, you can create a member variable of the class. This variable can be updated and reused by any other function without you having to worry about passing parameters. class Projet(object): def pathDirectory(self): print "- - in pathDirectory - -" self.pathDir= str(QFileDialog.getExistingDirectory(ui.pathTab1, 'Select...

Why my function return an array with only one element?

javascript,arrays,return

You should not be comparing initNum to currCompose. Keep in mind that initNum is the number you are checking (say, 71), and currCompose will be at most ceil(sqrt(initNum)) (say 9), so the two will never be equal. Also note that it is best to append to the list and verify...

Return json array from client to spring controller

json,spring,return

@RequestMapping (value="/ajax", method=RequestMethod.POST, consumes = "application/json") public @ResponseBody JSONObject post( @RequestBody JSONObject person) { //Pass data to a service to process the JSON } For your ajax request, do not set dataType to 'Text'. Set it to JSON $.ajax({ url: "http://localhost:8080/ajax", type: 'POST', dataType: 'json', data: JSON.stringify(ajax_data), contentType: 'application/json', success:...

Why can't I return this vector of vectors?

c++,vector,reference,return

The issue is that your return type is a reference to a Mapa. The Mapa (named temp inside the function) you're returning is destructed when the function goes out of scope, so you're returning a destructed Mapa, which is undefined. The solution is simple, return by value instead of by...

Java “add return statement” error

java,return,unreachable-statement

You need a return in the else case. public class1 foo ( class1 t) { if ( object == null ) return t; else return foo(t.childObject); } ...

When to use exit() over return? [duplicate]

c++,c,return,exit

These two are very different in nature. exit() is used when you want to terminate program immediately. If a call to exit() is encountered from any part of the application, the application finishes execution. return is used to return the program execution control to the caller function. In case of...

Remove element after returning a value from it

jquery,return

Why not store the value you want to return in a variable? Then return it when everything else is done function myFunc(a) { var d = $("<div>"); d.css("color",a).appendTo("body"); var color = d.css("color"); d.remove(); return color; } ...

Returning a formatted string does not working properly

java,format,return,duplicates,string.format

If you store usernames using %03d, i.e. with leading zeros, you also should use this when you compare the string in your userNameList: userNameList.get(i).equals(String.format("%s%s%03d", p1, p2, p3)) ...

How to return 2 Strings in one method: String example(String firstName, String secondName)

java,string,methods,return

A method could return only one value at a time. Either concatenate the both the strings and return or you could use a class. set the details and return the instance of that class Approach 1: return firstname+"|"+secondname; If you want those separate in calling method just use return_value.split("|"). Now...

Can someone please explain what “var result=1” is doing in this function?

javascript,return

The inside of the loop is taking result's current value, and multiplying it by the base (an argument to the function). Since 0 * anything is 0, and undefined * anything is NaN, it needs to be set up as 1 first. 3 ^ 0 = 1 3 ^ 1...

Matlab Reintroduction of AR and GARCH processes

matlab,for-loop,return,time-series,volatility

I think you are a bit confused about how matrix indexing works in Matlab. If understood correctly, you have a variable TR_t with which you want to store the value for time t. You then try to do the following: TR_t = TR_{t-1} * exp(R_t); I will try to explain...

How to return multiple values without using Collections?

java,string,methods,collections,return

As I understand it: private static String displayMultiple(Displayable d, int count){ String s = ""; String ss = d.getDisplayText(); for(int i=0; i<count; i++){ s += ss; } return s; } ...

JS why is other code ignored and only return executed

javascript,return

In the first version a() is only called once, so number++ is only called once. In the second version you call a() with every iteration so number++ is called on every iteration. So in the first version b is always the same function and in the second you get a...

Gulp task runs much faster without 'return' statement - why is that?

build,return,task,gulp

After some investigation I found that when return is used on Gulp task it's not actually slower at all, it just returns correct time it took to finish the task. It only felt faster since without return statement it essentially returned result as completed almost instantly, so the task time...

variable obj might not have been initialized

java,variables,object,return

Local variables need to be initialized before being used in this case before return. Though you are initializing it with but that is under if block obj = new NationalMessage(lines[0], lines[1], lines[2]); Compiler does not know whether it will be actually initializing at runtime or not because it's conditional. So...

TypeError: 'NoneType' object is not iterable when calling keys function

function,return,typeerror,iterable,nonetype

the problem comes as you try to "unpack" a NoneType like this: >>> x, y = None Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'NoneType' object is not iterable So we can conclude that this Manager.movementKeys(self, xShift, yShift) returns None I would guess that if...

python 3.4.3 basic return issue

python,return

In your hello function, the code prints "hello" and then returns the result 1234 to the caller. If this result (1234) is not printed to the console, nothing else is added and the program will go on without displaying the returned number. In order to display the number (1234), you...

Is it possible to return multiple items in my methods?

java,return,time-complexity

In java you cannot return multiple values separately. What you could do is, you could add all the values to be returned to a list and then return the reference to the list. Something like this : List<Double> doubleList = new ArrayList<>(); doubleList.add(max); // index 0 doubleList.add(maxelement); // index 1...