ruby-tut-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ruby-tut] Comments/Errata


From: Davis, James (NIH/CIT)
Subject: [ruby-tut] Comments/Errata
Date: Fri, 2 May 2003 09:05:01 -0400

Defining your own classes and methods / Classes and methods

    Suggestion:
    = The class keyword defines a class.
    + "Address" is the name of the class.  Note that classes begin
      with an uppercase letter.
      
   Comment: "Every class must contain an initialize method."
   Not really.  Ruby won't complain if you don't define an
   initialize method, since the method exists in the class
   hierarchy.
   
   Typo:
   - address = Addres.new("23 St George St.")
   + address = Address.new("23 St George St.")
   
   Suggestion:
   + When you call the Address.new method, it creates an empty
     instance of class Address, then invokes the initialize method
     with any parameters that were passed to new.  The initialize
     method contains code to set up the object as desired.


Defining your own classes and methods / Classes and methods /
Reading the data in an object

   Comment: "Ruby offers you a shortcut through the attr_reader keyword:"
   Actually, attr_reader, attr_writer, and attr_accessor are private
   methods of Module, not keywords.  They create methods, as can be
   demonstrated by Address.public_instance_methods.
   

Defining your own classes and methods / More on classes /
Class Person

    Typo:
    - Since we default all values to "", we are free to creat
    + Since we default all values to "", we are free to create
    

Defining your own classes and methods / Implementing AddressBook
Automatic sorting

    Typo:
    - What I mean by that is what when
    + What I mean by that is that when
          or
    + What I mean by that is when
    

Defining your own classes and methods / Implementing AddressBook
Automatic sorting / How do we sort an array?

    Phrasing:
    - In the section Sorting the addressbook had something like this:
    + In the section Sorting the addressbook we had something like this:
        or
    + The section Sorting the addressbook had something like this:
    

Defining your own classes and methods / More features /
Private and public methods
    
    Comment: "... public and private keywords."
    These are actually methods in Module.
     
    Phrasing?:
    - When you put the keyword private you set all the methods
    + When you specify private you set all the methods
    
    Typo/Phrasing:
    - until you change it back wit the public keyword.
    + until you change it back by specifying public.

    Phrasing?:
    - So, in our case, we just want to put the private keyword
    - before we define the by_name method.
    + So, in our case, we just want to specify private before
    + we define the by_name method.


Defining your own classes and methods / Writing good programs /
Comments

    Typo/Phrasing:
    - In AddresBook, the methods each and each_address have
    - only a one simple comment.
    + In AddressBook, the methods each and each_address have
    + only one simple comment.
    
    Typo:
    - Once you know that, it's use is also apparent.
    + Once you know that, its use is also apparent.


- Jim -




reply via email to

[Prev in Thread] Current Thread [Next in Thread]