Containers

Hai,

  I have a problem with ruby containers.what is the differnce

between containers and classes.Is there any syntax for containers.can
you please
reply me.

Subbaraju Datla wrote:

Hai,

  I have a problem with ruby containers.what is the differnce

between containers and classes.Is there any syntax for containers.can
you please
reply me.

AFAIK ‘container’ is just a general word for the classes that let you
contain objects: Hash and Array are the most commonly used example, but
you have others such as Queue. You could also view String as a
container class as it ‘contains’ characters.

There’s no ‘Container’ class, so there’s no syntax for containers,
although the classes that are referred to as containers (Hash, Array,
String etc) may define some common methods such as size (aka length).
This isn’t required though.

On 22.01.2009 13:43, Max W. wrote:

Subbaraju Datla wrote:

Hai,

Shark?

  I have a problem with ruby containers.what is the differnce

between containers and classes.Is there any syntax for containers.can
you please
reply me.

AFAIK ‘container’ is just a general word for the classes that let you
contain objects: Hash and Array are the most commonly used example, but
you have others such as Queue. You could also view String as a
container class as it ‘contains’ characters.

I’d add: it’s typical for a container class to contain arbitrary many
instances of other classes.

There’s no ‘Container’ class, so there’s no syntax for containers,
although the classes that are referred to as containers (Hash, Array,
String etc) may define some common methods such as size (aka length).
This isn’t required though.

Adding to that there is special syntax in Ruby, namely

this_is_a_hash = {1=>2, 3=>4}
this_is_an_array = [1,234,23,2]

Kind regards

robert