diff --git a/core/array.rbs b/core/array.rbs
index 03d3f13a63..188e0df81e 100644
--- a/core/array.rbs
+++ b/core/array.rbs
@@ -546,8 +546,8 @@
# given block.
#
%a{annotate:rdoc:source:from=array.c}
-class Array[unchecked out Elem] < Object
- include Enumerable[Elem]
+class Array[unchecked out E] < Object
+ include Enumerable[E]
#
# With a block given, calls the block with each element of `self`; returns a new
@@ -2007,8 +2007,8 @@ class Array[unchecked out Elem] < Object
#
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
#
- def filter: () { (Elem item) -> boolish } -> ::Array[Elem]
- | () -> ::Enumerator[Elem, ::Array[Elem]]
+ def filter: () { (E item) -> boolish } -> ::Array[E]
+ | () -> ::Enumerator[E, ::Array[E]]
#
# With a block given, calls the block with each element of `self`; removes from
@@ -2025,8 +2025,8 @@ class Array[unchecked out Elem] < Object
#
# Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
#
- def filter!: () { (Elem item) -> boolish } -> self?
- | () -> ::Enumerator[Elem, self?]
+ def filter!: () { (E item) -> boolish } -> self?
+ | () -> ::Enumerator[E, self?]
#
# Prepends the given `objects` to `self`:
@@ -2803,10 +2803,10 @@ class Array[unchecked out Elem] < Object
#
# Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
#
- def product: () -> ::Array[[ Elem ]]
- | [X] (::Array[X] other_ary) -> ::Array[[ Elem, X ]]
- | [X, Y] (::Array[X] other_ary1, ::Array[Y] other_ary2) -> ::Array[[ Elem, X, Y ]]
- | [U] (*::Array[U] other_arys) -> ::Array[::Array[Elem | U]]
+ def product: () -> ::Array[[ E ]]
+ | [X] (::Array[X] other_ary) -> ::Array[[ E, X ]]
+ | [X, Y] (::Array[X] other_ary1, ::Array[Y] other_ary2) -> ::Array[[ E, X, Y ]]
+ | [U] (*::Array[U] other_arys) -> ::Array[::Array[E | U]]
#
# Replaces the elements of `self` with the elements of `other_array`, which must
@@ -2976,7 +2976,7 @@ class Array[unchecked out Elem] < Object
#
# Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
#
- def replace: (::Array[Elem]) -> self
+ def replace: (::Array[E]) -> self
#
# Returns the new string formed by calling method #inspect on each
@@ -3820,7 +3820,7 @@ class Array[unchecked out Elem] < Object
#
# Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
#
- def union: [T] (*::Array[T] other_arys) -> ::Array[T | Elem]
+ def union: [T] (*::Array[T] other_arys) -> ::Array[T | E]
#
# Returns an array of flattened objects returned by the block.
@@ -399,8 +399,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
#
# Alias: #collect_concat.
#
- def collect_concat: [U] () { (Elem) -> (::Array[U] | U) } -> ::Array[U]
- | () -> ::Enumerator[Elem, ::Array[untyped]]
+ def collect_concat: [U] () { (E) -> (::Array[U] | U) } -> ::Array[U]
+ | () -> ::Enumerator[E, ::Array[untyped]]
#
# Returns the first element for which the block returns a truthy value.
@@ -488,8 +488,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
#
# With no block given, returns an Enumerator.
#
- def detect: (?Proc ifnone) { (Elem) -> boolish } -> Elem?
- | (?Proc ifnone) -> ::Enumerator[Elem, Elem?]
+ def detect: (?Proc ifnone) { (E) -> boolish } -> E?
+ | (?Proc ifnone) -> ::Enumerator[E, E?]
#
# Returns an array containing the items in `self`:
#
# (0..4).to_a # => [0, 1, 2, 3, 4]
#
- def entries: () -> ::Array[Elem]
+ def entries: () -> ::Array[E]
def enum_for: (Symbol method, *untyped, **untyped) ?{ (?) -> Integer } -> Enumerator[untyped, untyped]
- | () ?{ () -> Integer } -> Enumerator[Elem, self]
+ | () ?{ () -> Integer } -> Enumerator[E, self]
%a{annotate:rdoc:skip}
alias to_enum enum_for
@@ -639,8 +639,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
#
# Related: #reject.
#
- def find_all: () { (Elem) -> boolish } -> ::Array[Elem]
- | () -> ::Enumerator[Elem, ::Array[Elem]]
+ def find_all: () { (E) -> boolish } -> ::Array[E]
+ | () -> ::Enumerator[E, ::Array[E]]
#
# Returns an array containing elements selected by the block.
@@ -697,8 +697,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
# With no argument and no block given, returns an Enumerator.
#
def find_index: (untyped value) -> Integer?
- | () { (Elem) -> boolish } -> Integer?
- | () -> ::Enumerator[Elem, Integer?]
+ | () { (E) -> boolish } -> Integer?
+ | () -> ::Enumerator[E, Integer?]
#
# Returns whether for any element object == element:
@@ -972,8 +972,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
#
def inject: (untyped init, Symbol method) -> untyped
| (Symbol method) -> untyped
- | [A] (A initial) { (A, Elem) -> A } -> A
- | () { (Elem, Elem) -> Elem } -> Elem
+ | [A] (A initial) { (A, E) -> A } -> A
+ | () { (E, E) -> E } -> E
#
# Returns an array of objects returned by the block.
@@ -1645,8 +1645,8 @@ module Enumerable[unchecked out Elem] : _Each[Elem]
#
# With no block given, returns an Enumerator.
#
- def map: [U] () { (Elem arg0) -> U } -> ::Array[U]
- | () -> ::Enumerator[Elem, ::Array[untyped]]
+ def map: [U] () { (E arg0) -> U } -> ::Array[U]
+ | () -> ::Enumerator[E, ::Array[untyped]]
#
# Iterates the given block for each element with an arbitrary object, `obj`, and
@@ -541,17 +541,17 @@ class Enumerator[unchecked out Elem, out Return = void] < Object
# # => foo: 1
# # => foo: 2
#
- def with_object: [U] (U obj) { (Elem, U obj) -> untyped } -> U
- | [U] (U obj) -> ::Enumerator[[ Elem, U ], U]
+ def with_object: [U] (U obj) { (E, U obj) -> untyped } -> U
+ | [U] (U obj) -> ::Enumerator[[ E, U ], U]
end
#
# Generator
#
-class Enumerator::Generator[out Elem] < Object
- include Enumerable[Elem]
+class Enumerator::Generator[out E] < Object
+ include Enumerable[E]
- def each: () { (Elem) -> void } -> void
+ def each: () { (E) -> void } -> void
end
#
@@ -620,7 +620,7 @@ end
# # This returns an array of items like a normal enumerator does.
# all_checked = active_items.select(&:checked)
#
-class Enumerator::Lazy[out Elem, out Return = void] < Enumerator[Elem, Return]
+class Enumerator::Lazy[out E, out R = void] < Enumerator[E, R]
#
# Expands `lazy` enumerator to an array. See Enumerable#to_a.
#
@@ -632,7 +632,7 @@ class Enumerator::Lazy[out Elem, out Return = void] < Enumerator[Elem, Return]
# -->
# Like Enumerable#compact, but chains operation to be lazy-evaluated.
#
- def compact: () -> Enumerator::Lazy[Elem, Return]
+ def compact: () -> Enumerator::Lazy[E, R]
#
# Returns a non-lazy Enumerator converted from the lazy enumerator.
#
- def eager: () -> ::Enumerator[Elem, Return]
+ def eager: () -> ::Enumerator[E, R]
end
#
@@ -675,7 +675,7 @@ end
#
# This type of objects can be created by Enumerable#chain and Enumerator#+.
#
-class Enumerator::Chain[out Elem] < Enumerator[Elem, void]
+class Enumerator::Chain[out E] < Enumerator[E, void]
#
# Enumerator::Product generates a Cartesian product of any number of enumerable
# objects. Iterating over the product of enumerable objects is roughly
@@ -30,7 +30,7 @@ class Enumerator[unchecked out Elem, out Return = void]
#
# This type of objects can be created by Enumerator.product.
#
- class Product[unchecked out Elem] < Enumerator[Array[Elem], Product[Elem]]
+ class Product[unchecked out E] < Enumerator[Array[E], Product[E]]
#
# Returns `true` if `key` is a key in `self`, otherwise `false`.
#
- def key?: (Key) -> bool
+ def key?: (K) -> bool
end
end
diff --git a/core/range.rbs b/core/range.rbs
index 11d1a531f5..296891b3ea 100644
--- a/core/range.rbs
+++ b/core/range.rbs
@@ -235,8 +235,8 @@
#
# require 'json/add/range'
#
-class Range[out Elem] < Object
- include Enumerable[Elem]
+class Range[out E] < Object
+ include Enumerable[E]
#
# Returns the values in `self` as an array:
@@ -441,8 +441,8 @@ class Struct[Elem]
#
# Related: #each_pair.
#
- def each: () -> Enumerator[Elem, self]
- | () { (Elem value) -> void } -> self
+ def each: () -> Enumerator[E, self]
+ | () { (E value) -> void } -> self
#
# With a block given, returns an array of values from `self` for which the block
@@ -591,7 +591,7 @@ class Struct[Elem]
# Raises RangeError if any element of the range is negative and out of range;
# see Array@Array+Indexes.
#
- def values_at: (*int | range[int?] positions) -> Array[Elem]
+ def values_at: (*int | range[int?] positions) -> Array[E]
#
@@ -664,5 +664,5 @@ class Struct[Elem]
# h = joe.deconstruct_keys(nil)
# h # => {:name=>"Joseph Smith, Jr.", :address=>"123 Maple, Anytown NC", :zip=>12345}
#
- def deconstruct_keys: (Array[index & Hash::_Key]? indices) -> Hash[index & Hash::_Key, Elem]
+ def deconstruct_keys: (Array[index & Hash::_Key]? indices) -> Hash[index & Hash::_Key, E]
end
diff --git a/core/thread.rbs b/core/thread.rbs
index d47803fc6c..b3e7d78c17 100644
--- a/core/thread.rbs
+++ b/core/thread.rbs
@@ -1604,7 +1604,7 @@ end
#
# consumer.join
#
-class Thread::Queue[Elem = untyped] < Object
+class Thread::Queue[E = untyped] < Object
#
# Pushes the given `object` to the queue.
#
@@ -1719,7 +1719,7 @@ class Thread::Queue[Elem = untyped] < Object
# If `timeout` seconds have passed and no data is available `nil` is returned.
# If `timeout` is `0` it returns immediately.
#
- def pop: (?boolish non_block, ?timeout: _ToF?) -> Elem?
+ def pop: (?boolish non_block, ?timeout: _ToF?) -> E?
#
# Pushes the given `object` to the queue.
#
- def push: (Elem obj) -> void
+ def push: (E obj) -> void
#
# See #as_json.
#
- def self.json_create: [Elem] (Hash[String, String | Array[Elem]] object) -> Struct[Elem]
+ def self.json_create: [E] (Hash[String, String | Array[E]] object) -> Struct[E]
#
# Exception class to be raised when a cycle is found.
#
diff --git a/stdlib/tsort/0/interfaces.rbs b/stdlib/tsort/0/interfaces.rbs
index d560681a4f..8d410d9397 100644
--- a/stdlib/tsort/0/interfaces.rbs
+++ b/stdlib/tsort/0/interfaces.rbs
@@ -1,20 +1,20 @@
%a{annotate:rdoc:skip}
-module TSort[Node]
- interface _Sortable[Node]
+module TSort[N]
+ interface _Sortable[N]
# #tsort_each_node is used to iterate for all nodes over a graph.
#
- def tsort_each_node: () { (Node) -> void } -> void
+ def tsort_each_node: () { (N) -> void } -> void
# #tsort_each_child is used to iterate for child nodes of node.
#
- def tsort_each_child: (Node) { (Node) -> void } -> void
+ def tsort_each_child: (N) { (N) -> void } -> void
end
- interface _EachNode[Node]
- def call: () { (Node) -> void } -> void
+ interface _EachNode[N]
+ def call: () { (N) -> void } -> void
end
- interface _EachChild[Node]
- def call: (Node) { (Node) -> void } -> void
+ interface _EachChild[N]
+ def call: (N) { (N) -> void } -> void
end
end
diff --git a/stdlib/tsort/0/tsort.rbs b/stdlib/tsort/0/tsort.rbs
index ec5b55cd2c..521f284a9b 100644
--- a/stdlib/tsort/0/tsort.rbs
+++ b/stdlib/tsort/0/tsort.rbs
@@ -113,7 +113,7 @@
# 1. Tarjan, "Depth First Search and Linear Graph Algorithms",
# *SIAM Journal on Computing*, Vol. 1, No. 2, pp. 146-160, June 1972.
#
-module TSort[Node] : TSort::_Sortable[Node]
+module TSort[N] : TSort::_Sortable[N]
#