nuby question re a method

Discussion in 'Ruby' started by Van Jacques, Dec 10, 2003.

  1. Van Jacques

    Van Jacques Guest

    I am new to ruby, and have a simple question.

    In the tutorial, I came across

    class AddressBook
    def each
    @persons.each { |p| yield p }
    end
    end

    defining the method each on the Class AddressBook (an array of hashes;
    the addressbook is an array of persons, each person is a hash;
    his name, address, etc.)

    Question 1.
    Is this the same as the following?

    class AddressBook
    def each
    @persons.each
    do |p|
    yield p
    end
    end
    end

    Question 2. Is my terminology correct? If not, is the meaning
    clear enough?

    Van
     
    Van Jacques, Dec 10, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Boris \BXS\ Schulz

    nuby question: f.rename(x,y) does not work

    Boris \BXS\ Schulz, Jan 3, 2004, in forum: Ruby
    Replies:
    4
    Views:
    102
    Boris \BXS\ Schulz
    Jan 3, 2004
  2. Peña, Botp
    Replies:
    1
    Views:
    261
    Robert Klemme
    Jan 24, 2004
  3. Harry
    Replies:
    2
    Views:
    112
    Samuel Kvarnbrink
    Jan 26, 2004
  4. Edwin Eyan Moragas

    nuby question: question marks in method names

    Edwin Eyan Moragas, Aug 30, 2004, in forum: Ruby
    Replies:
    0
    Views:
    150
    Edwin Eyan Moragas
    Aug 30, 2004
  5. Peña, Botp

    nuby: method defined in two classes

    Peña, Botp, Dec 7, 2005, in forum: Ruby
    Replies:
    2
    Views:
    94
    Joel VanderWerf
    Dec 7, 2005
Loading...

Share This Page