SHOW:
|
|
- or go back to the newest paste.
| 1 | - | >> def each_file n |
| 1 | + | >> def each_file n, &block |
| 2 | >> n.each do | |
| 3 | ?> |name| | |
| 4 | - | ?> yield File.open name, 'r' |
| 4 | + | ?> File.open name, 'r', &block |
| 5 | >> end | |
| 6 | >> end | |
| 7 | => nil | |
| 8 | >> f | |
| 9 | => ["d2", "d3"] | |
| 10 | >> each_file f do | |
| 11 | ?> |file| | |
| 12 | ?> file.each do | |
| 13 | ?> |line| | |
| 14 | ?> puts line | |
| 15 | >> end | |
| 16 | >> end | |
| 17 | x | |
| 18 | xx | |
| 19 | yy | |
| 20 | yyyyyy | |
| 21 | => ["d2", "d3"] | |
| 22 | >> |