Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Enumerator::_Each interface #1915

Merged
merged 1 commit into from
Jul 25, 2024
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
7 changes: 7 additions & 0 deletions core/enumerator.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@
class Enumerator[unchecked out Elem, out Return] < Object
include Enumerable[Elem]

# A convenience interface for `each` with optional block
#
interface _Each[out E, out R]
def each: () { (E) -> void } -> R
| () -> Enumerator[E, R]
end

# <!--
# rdoc-file=enumerator.c
# - Enumerator.produce(initial = nil) { |prev| block } -> enumerator
Expand Down
2 changes: 1 addition & 1 deletion docs/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Interface type denotes _type of a value which can be a subtype of the interface_

```rbs
_ToS # _ToS interface
::MyApp::_Each[String] # Interface name with namespace and type application
::Enumerator::_Each[String] # Interface name with namespace and type application
ParadoxV5 marked this conversation as resolved.
Show resolved Hide resolved
```

### Alias type
Expand Down