hmm, google groups is being a bit weird, anyway, I got an email from a
Nathan Baum in my inbox (and the email says it was sent to ml as well,
but it's not on the web interface...)
On Sun, Nov 15, 2009 at 10:44 PM, Nathan Baum
<
natha...@parenthephobia.org.uk> wrote:
> This second snippet seems to be missing any call to Range().
>
oops, meant
func main() {
for j := range Range(1, 20) {
fmt.Println("Loop ", j);
}
}
> So what you're saying, if I understand it correctly, is that when
> "range" is applied to a function call expression, it:
>
> 1. Makes a channel of the function's return type.
yeap
> 2. Invokes the function call in a goroutine, passing the channel as an
> special implied parameter.
without passing a channel, the channel is created for you
> 3. Returns the channel as its value.
yeap
Which also means you can then get values from it without using a loop
in a normal channel like fashion
func main() {
values = Range(1, 20);
first := <-values;
second := <-values;
fmt.Println("First and second : ", first, second):
}
...
:)