[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ruby-tut] Errata / Comments
From: |
Davis, James (NIH/CIT) |
Subject: |
[ruby-tut] Errata / Comments |
Date: |
Mon, 7 Apr 2003 14:41:13 -0400 |
Data structures / What can arrays do? / Array arithmetic
Suggestion:
Might want to mention that Array addition and
subtraction requires the brackets. E.g.,
names + [ "Joel" ]
Data structures / What can arrays do? / Printing arrays
Typo:
- Remember that the nill
+ Remember that the nil
Data structures / Iterators / Exercises
Suggestion: Possible exercise
Given these parallel arrays,
zips = [12202, 02101, 60601, 48201]
cities = ["Albany", "Boston", "Chicago", "Detroit"]
write a program that prompts the user for a zip code,
then finds and prints the city name.
Suggestion: Possible exercise
Given this array,
zip_cities = [[12202,"Albany"],[02101,"Boston"], \
[60601,"Chicago"],[48201,"Detroit"]]
write a program that prompts the user for a zip code,
then finds and prints the city name.
Data structures / Hashes / Some terminology: keys and values
Phrasing:
- So, in the above example, the keys are "first name",
"last name" and "city" are some of the keys.
+ So, in the above example, "first name", "last name"
and "city" are some of the keys.
Data structures / Hashes / Exercises
Suggestion: Possible exercise
Given this hash,
zip_cities = {12202 => "Albany",
02101 => "Boston",
60601 => "Chicago",
48201 => "Detroit"}
write a program that prompts the user for a zip code,
then finds and prints the city name. How does this
exercise compare with the similar exercise given earlier
for arrays? Is an iterator needed? This type of hash
is referred to as an Associative Array.
Data structures / Example: Addressbook / First step: requirements
Typo:
- The address book contains a group of contacts .
+ The address book contains a group of contacts.
Phrasing:
- We are going to tackle these starting and the
address structure and finishing the the addressbook.
+ We are going to tackle these starting with the
address structure and finishing with the addressbook.
Data structures / Example: Addressbook / Third step: Persons
Typo:
- ... so we definitelly need a hash.
+ ... so we definitely need a hash.
Suggestion:
+ Note that each person's data is stored in a hash
variable, and the value of each "address" key is
also stored in a hash variable.
Typo:
- Data structures / Example: Addressbook / Excercises
+ Data structures / Example: Addressbook / Exercises
Data structures / Printing the addressbook / Phone number
Inconsistency:
- Phone number:
+ Phone number
Data structures / Printing the addressbook / Address
Typo:
- Finally add the address and a sepparation between the entries.
+ Finally, add the address and a separation between the entries.
Typo in code:
- # A blank line to sepparate entries.
+ # A blank line to separate entries.
Data structures / Sorting the addressbook / A second look at Array#sort
Typo:
- We know that, by defalt
+ We know that, by default
Data structures / Sorting the addressbook / The <=> operator
Inconsistency:
- The <=> operator.
+ The <=> operator
Typo:
- Sorting is so common, that there is an operator to simplyfy
+ Sorting is so common, that there is an operator to simplify
Data structures / Writing good programs / Good programming techniques
Phrasing:
- If you a collection of disparate data
+ If you have a collection of disparate data
More later,
- Jim -
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [ruby-tut] Errata / Comments,
Davis, James (NIH/CIT) <=