Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > nuby question re a method

Reply
Thread Tools

nuby question re a method

 
 
Van Jacques
Guest
Posts: n/a
 
      12-10-2003
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
nuby: method defined in two classes Peņa, Botp Ruby 2 12-07-2005 07:14 AM
nuby question: question marks in method names Edwin Eyan Moragas Ruby 0 08-30-2004 07:11 AM
amrita-nuby question: generate "id=" Harry Ruby 2 01-26-2004 06:54 PM
nuby: determine method passed and determine the receiver that received the method Peņa, Botp Ruby 1 01-24-2004 07:51 PM
nuby question: f.rename(x,y) does not work Boris \BXS\ Schulz Ruby 4 01-03-2004 04:19 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57