T
Thufir
Where does "food" come from in the example below? The declaration is
within the block? The varaible food exists only within the block?
What is (are) the value(s) for "food"?
Read the following aloud to yourself.
['toast', 'cheese', 'wine'].each { |food| print food.capitalize }
While this bit of code is less readable and sentence-like than the
previous examples, I'd still encourage you to read it aloud. While
Ruby may sometimes read like English, it sometimes reads as a shorter
English. Fully translated into English, you might read the above as:
With the words 'toast', 'cheese', and 'wine': take each food and print
it capitalized.
The computer then courteously responds: Toast, Cheese and Wine.
<http://poignantguide.net/ruby/chapter-3.html#section1>
thanks,
Thufir
within the block? The varaible food exists only within the block?
What is (are) the value(s) for "food"?
Read the following aloud to yourself.
['toast', 'cheese', 'wine'].each { |food| print food.capitalize }
While this bit of code is less readable and sentence-like than the
previous examples, I'd still encourage you to read it aloud. While
Ruby may sometimes read like English, it sometimes reads as a shorter
English. Fully translated into English, you might read the above as:
With the words 'toast', 'cheese', and 'wine': take each food and print
it capitalized.
The computer then courteously responds: Toast, Cheese and Wine.
<http://poignantguide.net/ruby/chapter-3.html#section1>
thanks,
Thufir