return

Caching IEnumerable

public IEnumerable<ModuleData> ListModules() { foreach (XElement m in Source.Descendants("Module")) { yield return new ModuleData(m.Element("ModuleID").Value); } } Initially the above code is great since there is no need to evaluate the entire collection if it is not needed. However, once all the Modules have been ...

How to return XML in an Zend Framework Application

Hi all, I'm having problems returning XML in my ZF Application. Below is the code I have: <?php class ProjectsController extends Gid_Controller_Action { public function xmlAction () { $content = "<?xml version='1.0'><foo>bar</foo>"; header('Content-Type: text/xml'); echo $content; } } ?> I've also tried the following: <?php...

Paypal Unsubscribe return url

Hi, I have created a paypal Unsubscribe button in Java , when user click on it and after login to paypal account and unsubscribes , the paypal posts on the notifyurl successfully and i am able to update my database.But i want to return to my site after unsubscription. But not able to do so. Is there any way so that i can return t...

tableView:viewForHeaderInSection: default value??

I want to have a single custom section header, with the rest being the default header. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { return ???; } What do I return to just give the default header view? ...

Does return inside an if() which is inside a for() - return from the if() or the for() ?

Ok, I'm unsure if my return line will end the for() loop or just the if() question? Example: for(;;) { wait(1); if(something) { tokens = strTok(something, " ") if(tokens.size < 2) return; } } I'm guessing that it'll just return from the if(something) question but I just want to be sure... ...

Returning a const reference to vector of an object

Hi there, I have 2 questions related to the same problem: 1) How to return a reference to a vector which belongs to a class. I have this class: class sys{ protected: vector<int> s; public: sys(); vector<int>& getS() {return s;} //(1) }; (1) should return the reference of the vector s. However in the main: main(){ ...

How to return names in alphabetical order?

I have two names from a user. I want to compare them and display them in alphabetical order. I tried the compareTo method, but that only returns an int. EDIT: Answer found! Thanks again guys! ...

Question about return statements.

import java.util.Scanner; public class GregorianYear { private int year; public GregorianYear(int a) { year = a; } public void SetYear() { System.out.println( "The year is: " ); Scanner kbd = new Scanner( System.in ); year = kbd.nextInt(); } public int getYear() { ...

"SELECT TOP 1" equality for codeigniter?

Hi Friends, I need to get only 1 record from sql result. we use "SELECT TOP 1" in standard sql, but how can we do that in CodeIgniter? Is there any func for that? I researched so much on net, but could not find :/ appreciate! thanks, ...

Best practice in python for return value on error vs. success.

Hi, In general, let's say you have a method like the below. def intersect_two_lists(self, list1, list2): if not list1: self.trap_error("union_two_lists: list1 must not be empty.") return False if not list2: self.trap_error("union_two_lists: list2 must not be empty.") return False #http://byt...

Return value from ajax call?

Hi, I'm making a basic ajax function in jquery which echoes the number of rows found in a MySQL Query. function checkEventIDClass(id) { var params = 'method=checkEventIDClash&table=test&id=' + id; $.ajax({ type: "POST", url: "ajax.php", data: params, ...

Storing char array in a class and then returning it

Hi, I need to store a char array inside a class and then return it. I have to admit that I'm a bit confused about pointers and have tried everything I can think of but can't get it to work. Here's what I have: #include <iostream> using namespace std; class Test { public: void setName(char *name); char getName(); private: c...

Make Ruby loop return "x" images rather than x, the integer

The following returns whatever integer I feed it as a parameter. def space(spacer_count) spacer_count.times do image_tag("24gray/spacer.png", :class => "spacer") end end How do I make it return the desired number of images? E.g., I want space(6) to return six copies of spacer.png, not the number "6". Thanks! ...

Access an Array Returned by a Function

Is there anyway to directly access the data returned in an array without a temporary variable? Currently, my code is as follows: function getData($id) { // mysql query return mysql_fetch_array($result); } $data = getData($id); echo $data['name']; Is there a direct way to get the returned data without the temporary variable? ...

java: different return types when overloading

Hi, I have a class tree like this: master class abstract class Cell AvCell extends Cell FCell extends Cell i have an abstract method getValue() in Cell Is it posibble to make the method getValue() to return int for AvCell and String for FCell? Can i use generics for int String? Thanks! ...

Number of levels in a tree in LISP

An n-ary tree is memorised in the following way: (node (list-subtree-1) (list-subtree-2) ...) As an example, the tree A / \ B C / \ D E is represented as follows: (A (B) (C (D) (E))) Return the number of levels of a tree The problem is that I am only allowed to use the following functions: null, car, cdr, equal, atom, ...

can php return a boolean? => return $aantal == 0;

hi very short question can php return a boolean like this: return $aantal == 0; like in java you can public boolean test(int i) { return i==0; } or do you Have to use a if contruction? because if i do this. $foutLoos = checkFoutloos($aantal); function checkFoutloos($aantal) { return $aantal == 0; } echo "foutLoos = $foutLoo...

Early return from a block given to instance_exec

In my application, I have the need to allow blocks to be defined and called within the scope of a class, using instance_exec (via Rails 2.3.2). However, some of these blocks need to return early in some situations, which is causing me a problem. My application was built using ruby 1.8.6, but I need to get it running on 1.8.7 as well. It...

C# web service ... return nested custom objects.

I've started developing a new web service in VS2005. There is only one method: [WebMethod] [XmlInclude(typeof(Person))] public PersonAction GetAction() { PersonAction action = new PersonAction(); return action; } where PersonAction class contains a field with a reference to a Person class [Serializable] public ...

javascript function return not working.

Hey, I have a problem returning a variable in my function, the below script works fine: function sessionStatus(){ $(document).ready(function(){ $.getJSON(scriptRoot+"sessionStatus.php",function(status){ alert(status); }); }); } sessionStatus(); Bet when I try the following I get a message box with the message...