objects

Using for-each over an array of Objects - "Integer[] array" - Why Does "for(int i : array)" Work?

Basically the title says it all. Why does using a primitive data type work in the second "for-each" loop when I am looping over an array of objects. Is there a casting back to the primitive equivalent of the Integer object occurring behind the scenes? import java.util.Arrays; import java.util.Collections; public class CodeTestingClas...

PHP Object Extension $this->some_object->method

I am trying to make a script in which different classes (e.g. Database, Utilities, Config) are all used to form one central Main class. I have tried extending a chain of them: Main -> Utilities -> Database -> Configuration But how can I set the different parts so that they can be called like this: <?php $this->db->select("WAFFLE...

Why my equals method won't work?

assertEquals(def.getMengs(), exp.getMengs()); fails, reporting: expected: java.util.HashSet<[...so geht die Legende ... ...legend has it ... ]> but was: java.util.HashSet<[...so geht die Legende ... ...legend has it ... ]> Indeed, through the debugger I see that both sets contain only one Meaning with objId = 1 for both. I expected th...

php: efficiently running functions with one-time loaded classes multiple times in optional files

Hello again, after reading the responses I have rewritten my question. Let's say I have a theoretical php application that uses objects that do different things. For every page that gets loaded by the application, different scripts will be run. now I made a simple php script that creates a simple object. (this is all made up, I'm just ...

How do I best create objects from configuration files?

I have a collection of PHP classes that can be instantiated traditionally using constructors. Now I want to add the ability to instantiate these objects using YAML configuration files. Here's an example of a configuration file describing a web form: title: Contact fields: message: type: text required: true topic...

Javascript 'this' keyword returning href attribute rather than Object on anchor tag

Requirement: Return the element object. Problem: Using the code below, I expected the links to return [object], but they actually return the string in the href attribute (or in the case of the first link, the Window object). (The HTML below has been tested in FireFox 3.6.8 and Internet Explorer 7 (7.0.6002.18005) with the same results.)...

C# objects in arrayLists. Please help!

Hello! I am working with arrayLists in C# and I am wondering how I can add objects to an arrayList and then retrieve the values from it? In short, how can I add, delete, edit and read from an Arraylist containing objects of classes? Thankful for all help! ...

Trying to sort a custom JavaScript object

Hi, I'm not too good at JS, but have survived thus far. I'm creating a sort-of complex JS object and wanting to sort it. The object's structure looks like this: cart.attributes = [ { Attribute, Value } ... ]; I'm creating a unique attribute that tells me 3 things separated arbitrarily by a colon: (Product ID):(Product...

How can I loop this (JSON)

{ "fulltime": [ {"name": "oscar godson", "age": "20", "email": "[email protected]"}, {"name": "daniel erickson", "age": "25", "email": "[email protected]"}, {"name": "john doe", "age": "18", "email": "[email protected]"} ], "parttime":[ {"name": "bill johnson", "age": "35"...

Combining values from 2 XML objects in PHP

Hi! ...well, actually I have an object which looks like this: object(AleParserXMLElement)#39 (4) { ["name:private"]=> string(6) "rowset" ["data:private"]=> object(SimpleXMLElement)#42 (2) { ["@attributes"]=> array(3) { ["name"]=> string(6) "skills" ["key"]=> string(6) "typeID" ["columns"]=> ...

With...End With VB6 Statement like Statement in objective-c

Wondering if we have something like vb6 with..End With Statement in Objective-c? Example: With Object .a = "aaa"; .b = "bbb"; End With I know that there is something called blocks concept, but i am not sure whether it is available in 10.5 Leopard. Thanks ...

PHP: How to loop through a dynamic number of classes

I'm wanting to detect all objects(classes) defined in a php file (example: flavors.php). The number of objects will be defined dynamically, so I need to process the available objects with a function at runtime until the objects are exhausted. After the objects are exhausted the program stops. I have full control over the code, so if the...

In JavaScript, is chained assignment okay?

Am not new to JS or its syntax, but sometimes, the semantics of the language has me stumped at times. At work today, a colleague mentioned this: var a = b = []; is not the same as var a = [], b = []; or var a = []; var b = []; since the first version actually assigns the reference to an empty array to a and b. I couldn't quite a...

Objective C objects behaving strangely (using old references)

I'm getting so very strange behavior in my Objective C library (for iPhone). What I'm trying to do is take packets coming in (off of the accessory port), append them into a NSMutableData instance variable, and then check that to see if I have any complete packets. If I do, the [containsPacket] method will return the length of the packet,...

querying object in rails (no activeRecord, using mongo with mongomapper)

I've got a group of messages in mongo which I am retrieving in rails with @messages = current_user.user_messages(@user) I now want to select the number of messages which were created in the last week, so I thought I could take the @messages and query that directly with @countRecent = @messages.count(:conditions => {:created_at =>{'$...

Perl: How to create objects on the fly?

My goal is to be able to use $obj like this: print $obj->hello() . $obj->{foo}; And I would like to create an object inline, maybe using something like this: my $obj = ( foo => 1, hello => sub { return 'world' } ); but when I try to use $obj as an object, I get an error saying that $obj has not been blessed. Is there some b...

sharing a string between two objects

I want two objects to share a single string object. How do I pass the string object from the first to the second such that any changes applied by one will be visible to the other? I am guessing that I would have to wrap the string in a sort of buffer object and do all sorts of complexity to get it to work. However, I have a tendency...

c# How to reference a dynamically created component?

Hi I have some code that create a few components on the click of a button. Something like this. CheckBox chk = new CheckBox(); chk.Top = 50; chk.Left = 50; chk.Text = "Check Box Test"; chk.Name = "chkTest" this.Controls.Add(chk); So how do I use this component. For example I tried this but got and error saying the component didn't ex...

Ruby - dealing with object hash

I have an issue dealing with a hash of objects. My hashes are player names, and the object has a property @name also. I am trying to iterate over multiple players, and be able to use their methods and such with rather clean code. Here is how I create the hash: puts "Who all is playing?" gets.split.each do |p| players[p] = Player.ne...

Object reference not set to an instance of an object with a class with an array of classes as a member

Here is the structure that I have: Friend Class StandardFormatFile Friend fileType As String Friend numberOfSeries As Integer Friend standardSeriesData As New ArrayList End Class Friend Class StandardFormatFileSeries Friend standardNumOfElements As Integer Friend standardSeriesName As String Friend standardDat...