Thanks for the input guys. This really helps. Sorry about the confusion with OR, I forgot that || actually means OR in most languages. I have heard |var| called goal-post notation (I think it was in a ROR podcast...) - is that what you call it ? I owuld guess another valid name is something with the word "pipes". Cheers, Tuka Dave Burt wrote: > Tuka Opaleye wrote: >> I am trying to get my head around the || symbol used extensively in >> ruby. To me it is somewhat foreign still and I am trying a few exercise >> to make it click. Can anyone suggest a phrase (pseudolanguage) that >> accurately expresses the possible expressions using || ? >> >> input.each_byte do |b| >> case b >> ... >> end >> for each byte in input, assign it to b... > > You're right, assignment is correct. Imagine a special variable > yielded_values; the block could be expressed like this: > > do > b = *yielded_values > case b > ... > end > end > > Implicit in this is that you can use full assignment semantics, as in > this idiom: > > my_hash.inject(initial_value) do |memo, (key, value)| > ... > end > > It works this way: inject yields a [memo, whatever_each_yields] pair, > and Hash#each yields a [key, value] pair. This is the analogous > assignment: > > yielded_values = [:memo, [:key, :value]] > memo, (key, value) = *yielded_values > > How would you say this in English? Inject is problematic this way; I > don't understand how to explain it naturally using the word "inject" at > all. But perhaps you could use a general form such as "call inject with > the parameter initial_value and a block taking parameters memo, key and > value." > >> Ex 2: >> open('smiley.html', 'wb') do |f| >> f << ... >> end >> >> Sugestions ?..... > > *With* an open binary-write mode file handle to "smiley.html" *as* f... > > What a block means depends on the method. You've looked at iteration and > scope-of-an-opened-object examples, which are probably the most common, > but there are others (e.g. Markaby). > > Cheers, > Dave -- Posted via http://www.ruby-forum.com/.