2011/5/25 Yusuke Endoh <mame / tsg.ne.jp>:

> - * Note that enumeration sequence by next_values method does not affect other
> - * non-external enumeration methods, unless underlying iteration
> - * methods itself has side-effect, e.g. IO#each_line.
> + * Note that enumeration sequenced by +next_values+ does not affect other
> + * non-external enumeration methods, unless underlying iteration methods
> + * itself has side-effect, e.g. IO#each_line.
>
> I cannot undestand what "enumeration sequence by next_values" is.
> This is a problem of the original rdoc, not yours, though.
> It might be good to remove "enumeration sequence by".
>
> The old rdoc was written by akr.  Akr, what did you mean?

For example, next_values doesn't affect Array#each as follows.

% ruby -e '
obj = [1,2,3,4]
enum = obj.each
obj.each {|x|
  p x
  enum.next_values
}
'
1
2
3
4
% ruby -e '
obj = [1,2,3,4]
enum = obj.each
obj.each {|x|
  p x
}
'
1
2
3
4

The sequence (1, 2, 3, 4) is not changed by enum.next_values call.

But next_values affect IO#each as follows.

% print -l a b c d|ruby -e '
obj = STDIN
enum = obj.each
obj.each {|x|
  p x
  enum.next_values
}
'
"a\n"
"c\n"
% print -l a b c d|ruby -e '
obj = STDIN
enum = obj.each
obj.each {|x|
  p x
}
'
"a\n"
"b\n"
"c\n"
"d\n"
-- 
Tanaka Akira