views:

42

answers:

2

INTRODUCTION : I have a function(callback) that receives a object as an argument, inside this function I have a method(or function I'm note sure what is it) which then partitions that object. Now I'll add some code to add some clarification to introduction part.

Result.getListCallback = function(obj) {
Result.complexObject = obj.data;     

 var objectPartitioner = Result.complexObject.partition( function(n){
    return n.case.id == Result.selectedData.case.id;
      });
}

What I want to do is to modify this "objectPartitioner" to return couple of things for me not just case.id , how can I do that , perhaps using several returns ? thank you

+2  A: 

Why not return an object? In this case, you can pack what you want.

Note that if you want to return something like a small array it is anyhow an object in Javascript.

jldupont
returning an array wouldn't be such a bad idea .. for example n.case.id -> integer, for instance I'd like to return n.point.xcord -> also integer/long doesn't matter and couple of those all with the same type .. how can I dod that ?
Gandalf StormCrow
you just set any property you deem necessary in the object and return it.
jldupont
A: 

Unfortunately, the only way to do this is to return a list, and if you're going to do that, you're better off returning an object that has mnemonics for variable names. Javascript objects are really just overblown arrays.

This is one of the great things I love about perl, you can return lists of values with names from your functions.

Chris Kaminski