Passing ranges around
Bahman Movaqar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jul 11 20:57:09 PDT 2016
What should be signature of `foo` in the following piece of code?
auto foo(range r) {
// do something with the `r`
}
void main() {
foo([1,2,3].map!(x => x*x));
}
Right now I use `.array` to convert the range before passing:
auto foo(int[] r) {
// do something with the `r`
}
void main() {
foo([1,2,3].map!(x => x*x).array);
}
But it doesn't feel right.
Thanks,
--
Bahman
More information about the Digitalmars-d-learn
mailing list