O'Reilly Forums: Pg 162 Hash Usage - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Pg 162 Hash Usage

#1 User is offline   lab999 

  • New Member
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 22-August 10

Posted 22 August 2010 - 04:49 PM

Could someone provide me with a more thorough explanation of the usage of Hash? In attempting to solve the 'sharpen your pencil' on page 161, I did not consider the use of Hash because the definition on page 152 stated: 'a variable that has exactly TWO COLUMNS'. Clearly, the proper usage of Hash is not making its way through the thick exterior of my skull to my brain. Any explanation for why this worked for the problem would be appreciated.

Thank you!
0

#2 User is offline   lab999 

  • New Member
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 22-August 10

Posted 23 August 2010 - 12:05 PM

After re-reading Chapter 5, as Paul suggested in another topic, I believe I've dispelled my confusion.

Hash: a variable that has exactly two columns and (potentially) many rows of data

The hash itself is the variable.
The two COLUMNS are: 1)the keys and 2)their associated values.
So 'ID' is a key. 'name' is a key. 'country' is a key. etc.
Each set of key and value is a row. There can be many, many key/value combinations, but there is ever only one column of keys and one column of values.

(I had been incorrectly picturing the keys in the Page 162 problem as columns across the top of a sql table: ID as one column, name as another, country as a third, etc.)

Slow...but I finally get there.

This post has been edited by lab999: 23 August 2010 - 12:10 PM

0

#3 User is offline   paulbarry 

  • Advanced Member
  • PipPipPipPipPipPipPipPip
  • Group: O'Reilly Author
  • Posts: 306
  • Joined: 20-August 09

Posted 23 August 2010 - 12:58 PM

QUOTE (lab999 @ Aug 23 2010, 12:05 PM) <{POST_SNAPBACK}>
Hash: a variable that has exactly two columns and (potentially) many rows of data

The hash itself is the variable.
The two COLUMNS are: 1)the keys and 2)their associated values.
So 'ID' is a key. 'name' is a key. 'country' is a key. etc.
Each set of key and value is a row. There can be many, many key/value combinations, but there is ever only one column of keys and one column of values.


Sorry... only seeing this now. But, yes, your description is correct. :-)

Paul.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users