Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ rbs_root = Gem.loaded_specs['rbs'].full_gem_path
stdlib_path core_root: 'core', stdlib_root: "#{rbs_root}/stdlib"
target :test do
check 'test'
signature 'test/sig'

configure_code_diagnostics(D::Ruby.strict)
end
12 changes: 12 additions & 0 deletions core/enumerable.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Enumerable[unchecked out Elem] : _Each[Elem]
interface _Each[unchecked out T]
def each: () { (T) -> void } -> void
end

# TODO: Array
# def collect: [T]() { (Elem item) -> T } -> Array[T]
#
# alias map collect

def each_with_index: () { (Elem item, Integer index) -> void } -> self
end
27 changes: 27 additions & 0 deletions test/enumerable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

# rubocop:disable Lint/Void
# rubocop:disable Style/Documentation

class EnumerableTestClass
include Enumerable

def each
yield 'Hello'
end
end

a = EnumerableTestClass.new
a.each { |item| item }

# TODO: Array
# a.collect { |item| item }
#
# a.map { |item| item }

a.each_with_index do |item, index|
item
index
end

# rubocop:enable all
5 changes: 5 additions & 0 deletions test/sig/enumerable.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class EnumerableTestClass
include Enumerable[String]

def each: () { (String) -> void } -> void
end