class
v1_9_1_378 -
Show latest stable
-
1 note
- Superclass:
Object
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180 (38)
- 1_9_3_125 (15)
- 1_9_3_392 (0)
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
A class which provides a method `each’ to be used as an Enumerable object.
Register or
log in
to add new notes.
stevecj -
September 14, 2015 - (v1_9_1_378 - v1_9_3_392)
0 thanks
Getting the return value from the underlying method of an Enumerator
This is documented in the example code, but easy to miss.
When you get an Enumerator using #to_enum(:method_name, …), you can get all of the yielded values using #next, but not the value that is finally returned.
That value can be retrieved via the #result attribute of the StopIteration exception object that is raised when calling #next after the underlying method has returned.