instance method Object#enum_for
to_enum(method = :each, *args) -> Enumerator
enum_for(method = :each, *args) -> Enumerator
-
Enumerator.new(self, method, *args) を返します。
- [PARAM] method:
- メソッド名の文字列かシンボルです。
- [PARAM] args:
- 呼び出すメソッドに渡される引数です。
- [EXCEPTION] NameError:
- 存在しないメソッド名を指定すると発生します。
str = "xyz" enum = str.enum_for(:each_byte) p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"] # protects an array from being modified a = [1, 2, 3] p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
[SEE_ALSO] Enumerator
class Object