Ruby: How do you set an Enumerator's state?
问题 I'm doing a base 64 permutation incrementor. I've already written all the working code. But seeing as how Ruby already as Array::permutation which produces an Enumerator; I'd like to use that and take it a step further. Without having to go through every permutation by using 'next', can I set the start point? x = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a + ['+','/'] y = x.permutation(12) y.peek.join => "ABCDEFGHIJKL" y.next y.peek.join => "ABCDEFGHIJKM" . # DO SOMETHING LIKE THIS y