[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Iterators vs Lambdas
- From: David Demelier <demelier.david@...>
- Date: Tue, 10 Sep 2013 18:27:51 +0200
Hi,
What do you guys prefer between iterators vs lambdas? For example, you
have a function find("/directory", "pattern") where the function will
find every entries that matches the pattern.
Would you rather use like that:
for entry in find("/directory/", "*bar")
-- Play with entry
end
Or with a lambda called with the entry as argument
find("/directory/", "*bar",
function (entry)
-- Play with entry
end
)
The second one maybe more performant (I guess, not tested) on huge
objects. Also the second one may use different function as parameter
without rewriting the for loop in the first one.
So I would like what you usually prefer before I'm going further in my
project because it will require a lot of these kind of calls :-).
Warm regards,
--
Demelier David