Ruby blocks
I often see these blocks after a method call like this:
Code:
File::open('filename', 'w') do |f| |
Quote:
|
How "low level" do you want to go?
The File::open method will yield the File object, this allows the block to use this object, once the block is closed the File::open method will then close the file. Because the File::open method has just a single yield the block will be executed once, but if within the method the yield is wrapped inside a while then you will get an iterator, as is the case with the IO.each (which File will inherit) |
All times are GMT -5. The time now is 05:05 PM. |