What is the Hash datatype in Ruby?

What is the Hash datatype in Ruby? And what is it used for?

Can anyone please explain with an example.

···

--
Posted via http://www.ruby-forum.com/.

http://www.ruby-doc.org/core/classes/Hash.html

···

On 30.07.2009 13:44, Prateek Agarwal wrote:

What is the Hash datatype in Ruby? And what is it used for?

Can anyone please explain with an example.

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

A hash is a collection of pieces of data where you access any selected
item via a key rather than by position (as with eg arrays and lists).

Whether Ruby does this I don't know but in the olden days hash implied
mapping a key into an address space using a randomizing algorithm which
as far as possible kept items at different addresses. If the hash
created a collision then the item would be moved to some predictable
offset position. It's therefore a sort of indexing mechanism that
doesn't require an index.

Arguably it makes sense to use a hash whenever you are dealing with
collections that are not accessed in a particular order.

···

--
Posted via http://www.ruby-forum.com/.

http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_containers.html#UB

···

Am Donnerstag, 30. Jul 2009, 20:44:05 +0900 schrieb Prateek Agarwal:

What is the Hash datatype in Ruby? And what is it used for?

Can anyone please explain with an example.

--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de