Forum: Ruby containers

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
231c8ac349b039f6b766fad1f30d7e38?d=identicon&s=25 Subbaraju Datla (subbu)
on 2009-01-22 13:00
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.
73c04e9ef9ca435c5b19a2e765ae6d20?d=identicon&s=25 Max Williams (max-williams)
on 2009-01-22 13:45
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.
E0d864d9677f3c1482a20152b7cac0e2?d=identicon&s=25 Robert Klemme (Guest)
on 2009-01-22 22:36
(Received via mailing list)
On 22.01.2009 13:43, Max Williams 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
This topic is locked and can not be replied to.