For instance:
// somefile.php
function doSomething() {
// do lots of code, whatever...
return $something;
}
// mainfile.php
include "somefile.php"
doSomething(); // ignored the return value, we don't need it here
What happens when a function in PHP returns a value but we don't care about it? Is something wrong with this behav...
I have a recursive function that returns a value.
public function getparent ($user)
{
$referrer=''; $pos=0;$this->setFieldNames();
$result=mysql_query("select * FROM ". $this->dbtablename ." WHERE ".$this->id_field . " = '$user'", $this->dbConnectionID);
while($row=mysql_fetch_array($result, MYSQL_ASSOC)...
I'm refactoring a large javascript document that I picked up from an open source project. A number of functions use inconsistent return statements. Here's a simple example of what I mean:
var func = function(param) {
if (!param) {
return;
}
// do stuff
return true;
}
Sometimes the functions return boolean, so...
Is it possible to return a standard container from a function without making a copy?
Example code:
std::vector<A> MyFunc();
...
std::vector<A> b = MyFunc();
As far as I understand, this copies the return value into a new vector b. Does making the function return references or something like that allow avoiding the copy?
...
A simple question, but I haven't found a definitive answer on Stack Overflow.
struct foo { int x; int y; int z; }
foo Func()
{
return new foo();
}
void Func2()
{
foo f = Func(); // did boxing and unboxing occur?
}
Is a C# struct (value type) always copied to the stack when returned fro...
Hello.
I need help. For this specific method. I am trying to get it to return an arraylist that I tokenized.
public ArrayList read (){
BufferedReader inputStream = null;
try {
inputStream = new BufferedReader(new FileReader("processes1.txt"));
String l;
while ((l = inputStream.readLine()) != null) {
ArrayLis...
Hi.
public function add($child){
return $this->children[]=$child;
}
Btw, this is an excerpt from PHP in Action by Dagfinn Reiersol. According to the book, this returns $child, but shouldn't it return true in case of successful assignment and false otherwise?
Thanks in advance
...
Hi,
I have this c code:
if(fork()==0){
execl("/usr/bin/fsck", "fsck", "/dev/c0d0p1s0", NULL);
}
it calls execl to run fsck for checking the filesystem /dev/c0d0p1s0.
My question is: how can I get the return value of fsck?
I need the return value of fsck to check whether the file system is consistence or not.
Thank you.
...
Hey guys, I was writing some code and I found a peculiar error. The function convert_vector2d(&i_scale) converts a string to a vector2d (inherits from sf::vector2f). If you examine the next few lines of code, I am doing the same operation twice.
Code: Select all
float x = convert_Vector2D(&i_scale).x;
float y = convert_Vector2D(&i_scal...
I can't find this anywhere, how do you check to see if slice is returning elements still in the list? Like $('.class').slice(n-th,n-th);
When n-th variables are increased throughout the index of the return class by slicing, how do you know when slice returns on an invalid index? Hope I explained that well.
Here is the example code of w...
I know it's been the convention in ANSI C to always return a 0 integer value from main in a C program, like this:
int main() {
/* do something useful here */
return 0;
}
This is to return a "successful" result to the operating system. I still consider myself a novice (or an intermediate programmer at best) in C, but to date...
We are using .Net 2.0 to create webservices. We would like to design webservices in ASP.Net 2.0.
Currently the webservices we have return either a single parameter like
<s:element name="ChangePassword">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string" />
<s:...
Hi All
I have a list of objects, which has a method that has a couple of out parameters. How do i call this method on each object, get the out parameter values and use them later on in the query, perhaps for checking in a where clause?
Is this possible and if so can someone please demonostrate through sample code.
Thanks!
...
Is it possible for you to return two values when calling a function that would output the values, for example, I have this:
<?php
function ids($uid = 0, $sid = '')
{
$uid = 1;
$sid = md5(time());
return $uid;
return $sid;
}
echo ids();
?>
Which will output 1, I want to chose what to ouput, e.g. ids($sid), but i...
Many standard C and POSIX functions return -1 for error, and 0 on success, for example truncate, fflush, msync, etc.
int ret = truncate("/some/file", 42);
Is it better practice to check for success with ret != -1 or ret == 0, and why?
My Thoughts
It's my experience most people check for the error case (ret != -1), as there is typica...
The topic of returning nulls, empty objects and empty collections came up today and we'd like to get the opinion of others. We have read the discussion on returning null for object and separately the discussion on returning empty collections and agree with the marked answers for both topics. However, in our case, we have a class that c...
int main(void){
printf("Hello World");
return 0;
}
How is 0 passed as return value in assembly level? Is there a dedicated CPU register for this job?
UPDATE
Here's the 2 tables on passing/return data in the pdf, but doesn't seems to have the exact info on how the calling convention of an API is determined and which register is use...
When browsing the source of a project on web I've found some weird to me return statement in main:
int main()
{
/* ... */
return 0x1;
}
So main is returning 0x1 radix 16, but that's 1 radix 10! Shouldn't main return 0?
That is incorrect, right? By the way is it Okay to return 0x0?
Thanks in advance.
...
I've come across some code that surrounds the return value from a method/function in parentheses.
What does that do?
The code I saw took an image, resized it and then returned it.
- (UIImage *)resizeImage:(UIImage *)image
{
//
// some fascinating, but irrelevant, resizing code here
//
return (image);
}
...
Hello, I have the following class
class node {
public:
node() { }
node(const node&);
node(luint inID) { ID = inID; }
~node() { neighbors.clear(); }
node& operator=(const node&);
void addNeighbor(luint);
void addNeighbor(const std::vector<luint>& );
void setID(luint inID) { ID = inID; }
luint getID() ...