Can you give an example or two? I'm not getting what this would do (simple or not :-)
-- David Black
I guess you should use 'enumerator' which is bundled with 1.8.
object.to_enum(method).inject(init){....}
Using enumerator, you can enumerate over any method, not just inject.
--matz.
For what it can do - this is what I used it for:
ifile, idir = *[:file?, :directory?].map {|sym|
Proc.new {|root| inject_with(Find, :find, [], root) {|arr, path|
FileTest.send(sym, path) ? arr << path : arr
}}
}
-- i.e. make procs to find all files and all directories using find. (simpler way to do that?) but it just seemed like a nice add on - but apparently enumerator can work. Is there documentation for enumerator somewhere in English?
You can find enumerator.txt in the ext/enumerator directory in the distribution archive.
--matz.
Can you give an example or two? I'm not getting what this would do (simple or not :-)
-- David Black
I guess you should use 'enumerator' which is bundled with 1.8.
Using enumerator, you can enumerate over any method, not just inject.
--matz.
For what it can do - this is what I used it for:
-- i.e. make procs to find all files and all directories using find. (simpler way to do that?) but it just seemed like a nice add on - but apparently enumerator can work. Is there documentation for enumerator somewhere in English?You can find enumerator.txt in the ext/enumerator directory in the distribution archive.
--matz.