rbs 0.12.2 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +8 -4
- data/.gitignore +0 -1
- data/CHANGELOG.md +32 -0
- data/Gemfile +4 -0
- data/README.md +8 -2
- data/Rakefile +9 -2
- data/Steepfile +1 -1
- data/bin/annotate-with-rdoc +1 -1
- data/bin/setup +0 -2
- data/bin/test_runner.rb +15 -1
- data/{stdlib/builtin → core}/array.rbs +124 -120
- data/{stdlib/builtin → core}/basic_object.rbs +54 -54
- data/{stdlib/builtin → core}/binding.rbs +42 -42
- data/core/builtin.rbs +70 -0
- data/{stdlib/builtin → core}/class.rbs +33 -33
- data/{stdlib/builtin → core}/comparable.rbs +0 -0
- data/{stdlib/builtin → core}/complex.rbs +90 -90
- data/{stdlib/builtin → core}/constants.rbs +0 -0
- data/{stdlib/builtin → core}/data.rbs +0 -0
- data/{stdlib/builtin → core}/deprecated.rbs +0 -0
- data/{stdlib/builtin → core}/dir.rbs +0 -0
- data/{stdlib/builtin → core}/encoding.rbs +33 -33
- data/{stdlib/builtin → core}/enumerable.rbs +58 -52
- data/{stdlib/builtin → core}/enumerator.rbs +35 -35
- data/{stdlib/builtin → core}/errno.rbs +0 -0
- data/{stdlib/builtin → core}/errors.rbs +2 -2
- data/{stdlib/builtin → core}/exception.rbs +50 -50
- data/{stdlib/builtin → core}/false_class.rbs +6 -6
- data/{stdlib/builtin → core}/fiber.rbs +14 -14
- data/{stdlib/builtin → core}/fiber_error.rbs +1 -1
- data/{stdlib/builtin → core}/file.rbs +0 -0
- data/{stdlib/builtin → core}/file_test.rbs +0 -0
- data/{stdlib/builtin → core}/float.rbs +161 -161
- data/{stdlib/builtin → core}/gc.rbs +3 -3
- data/{stdlib/builtin → core}/hash.rbs +7 -7
- data/{stdlib/builtin → core}/integer.rbs +0 -0
- data/{stdlib/builtin → core}/io.rbs +88 -88
- data/{stdlib/builtin → core}/kernel.rbs +71 -153
- data/{stdlib/builtin → core}/marshal.rbs +0 -0
- data/{stdlib/builtin → core}/match_data.rbs +1 -1
- data/{stdlib/builtin → core}/math.rbs +0 -0
- data/{stdlib/builtin → core}/method.rbs +19 -19
- data/{stdlib/builtin → core}/module.rbs +13 -13
- data/{stdlib/builtin → core}/nil_class.rbs +20 -20
- data/{stdlib/builtin → core}/numeric.rbs +101 -101
- data/{stdlib/builtin → core}/object.rbs +173 -173
- data/{stdlib/builtin → core}/proc.rbs +91 -91
- data/{stdlib/builtin → core}/process.rbs +0 -0
- data/{stdlib/builtin → core}/random.rbs +1 -1
- data/{stdlib/builtin → core}/range.rbs +3 -5
- data/{stdlib/builtin → core}/rational.rbs +83 -83
- data/{stdlib/builtin → core}/rb_config.rbs +0 -0
- data/{stdlib/builtin → core}/regexp.rbs +0 -0
- data/{stdlib/builtin → core}/ruby_vm.rbs +0 -0
- data/{stdlib/builtin → core}/signal.rbs +7 -7
- data/{stdlib/builtin → core}/string.rbs +10 -10
- data/{stdlib/builtin → core}/string_io.rbs +8 -8
- data/{stdlib/builtin → core}/struct.rbs +1 -1
- data/{stdlib/builtin → core}/symbol.rbs +1 -1
- data/{stdlib/builtin → core}/thread.rbs +189 -189
- data/{stdlib/builtin → core}/thread_group.rbs +2 -2
- data/{stdlib/builtin → core}/time.rbs +0 -0
- data/{stdlib/builtin → core}/trace_point.rbs +0 -0
- data/{stdlib/builtin → core}/true_class.rbs +10 -10
- data/{stdlib/builtin → core}/unbound_method.rbs +0 -0
- data/{stdlib/builtin → core}/warning.rbs +1 -1
- data/docs/CONTRIBUTING.md +1 -0
- data/docs/repo.md +125 -0
- data/docs/syntax.md +50 -6
- data/goodcheck.yml +22 -5
- data/lib/rbs.rb +1 -0
- data/lib/rbs/ast/comment.rb +1 -1
- data/lib/rbs/cli.rb +117 -107
- data/lib/rbs/constant.rb +1 -1
- data/lib/rbs/constant_table.rb +9 -8
- data/lib/rbs/definition_builder.rb +6 -7
- data/lib/rbs/environment.rb +5 -1
- data/lib/rbs/environment_loader.rb +79 -105
- data/lib/rbs/namespace.rb +1 -1
- data/lib/rbs/parser.rb +3148 -0
- data/lib/rbs/parser.y +10 -3
- data/lib/rbs/prototype/rb.rb +38 -6
- data/lib/rbs/prototype/runtime.rb +17 -7
- data/lib/rbs/repository.rb +121 -0
- data/lib/rbs/test/hook.rb +2 -0
- data/lib/rbs/test/setup.rb +5 -3
- data/lib/rbs/test/setup_helper.rb +4 -4
- data/lib/rbs/test/tester.rb +4 -1
- data/lib/rbs/test/type_check.rb +12 -6
- data/lib/rbs/type_name.rb +3 -2
- data/lib/rbs/variance_calculator.rb +2 -2
- data/lib/rbs/vendorer.rb +38 -16
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +25 -15
- data/sig/cli.rbs +58 -0
- data/sig/constant.rbs +21 -0
- data/sig/constant_table.rbs +30 -0
- data/sig/declarations.rbs +2 -2
- data/sig/definition.rbs +2 -2
- data/sig/definition_builder.rbs +6 -5
- data/sig/environment_loader.rbs +100 -0
- data/sig/members.rbs +2 -2
- data/sig/method_types.rbs +1 -1
- data/sig/namespace.rbs +4 -4
- data/sig/parser.rbs +25 -0
- data/sig/polyfill.rbs +42 -0
- data/sig/rbs.rbs +8 -0
- data/sig/repository.rbs +79 -0
- data/sig/substitution.rbs +3 -3
- data/sig/typename.rbs +1 -1
- data/sig/types.rbs +1 -1
- data/sig/vendorer.rbs +44 -0
- data/sig/version.rbs +3 -0
- data/sig/writer.rbs +40 -0
- data/stdlib/abbrev/{abbrev.rbs → 0/abbrev.rbs} +0 -0
- data/stdlib/base64/{base64.rbs → 0/base64.rbs} +1 -1
- data/stdlib/benchmark/{benchmark.rbs → 0/benchmark.rbs} +2 -2
- data/stdlib/{bigdecimal/math → bigdecimal-math/0}/big_math.rbs +0 -0
- data/stdlib/bigdecimal/{big_decimal.rbs → 0/big_decimal.rbs} +0 -0
- data/stdlib/coverage/{coverage.rbs → 0/coverage.rbs} +2 -2
- data/stdlib/csv/{csv.rbs → 0/csv.rbs} +1 -1
- data/stdlib/date/{date.rbs → 0/date.rbs} +4 -4
- data/stdlib/date/{date_time.rbs → 0/date_time.rbs} +1 -1
- data/stdlib/dbm/0/dbm.rbs +277 -0
- data/stdlib/erb/{erb.rbs → 0/erb.rbs} +0 -0
- data/stdlib/fiber/{fiber.rbs → 0/fiber.rbs} +0 -0
- data/stdlib/find/{find.rbs → 0/find.rbs} +12 -12
- data/stdlib/forwardable/{forwardable.rbs → 0/forwardable.rbs} +0 -0
- data/stdlib/ipaddr/{ipaddr.rbs → 0/ipaddr.rbs} +0 -0
- data/stdlib/json/{json.rbs → 0/json.rbs} +0 -0
- data/stdlib/logger/{formatter.rbs → 0/formatter.rbs} +0 -0
- data/stdlib/logger/{log_device.rbs → 0/log_device.rbs} +1 -1
- data/stdlib/logger/{logger.rbs → 0/logger.rbs} +1 -1
- data/stdlib/logger/{period.rbs → 0/period.rbs} +0 -0
- data/stdlib/logger/{severity.rbs → 0/severity.rbs} +0 -0
- data/stdlib/mutex_m/{mutex_m.rbs → 0/mutex_m.rbs} +0 -0
- data/stdlib/pathname/{pathname.rbs → 0/pathname.rbs} +41 -39
- data/stdlib/prime/{integer-extension.rbs → 0/integer-extension.rbs} +0 -0
- data/stdlib/prime/{prime.rbs → 0/prime.rbs} +0 -0
- data/stdlib/pstore/0/pstore.rbs +287 -0
- data/stdlib/pty/{pty.rbs → 0/pty.rbs} +1 -1
- data/stdlib/securerandom/{securerandom.rbs → 0/securerandom.rbs} +0 -0
- data/stdlib/set/{set.rbs → 0/set.rbs} +0 -0
- data/stdlib/tmpdir/{tmpdir.rbs → 0/tmpdir.rbs} +12 -12
- data/stdlib/uri/{file.rbs → 0/file.rbs} +0 -0
- data/stdlib/uri/{generic.rbs → 0/generic.rbs} +2 -2
- data/stdlib/uri/0/http.rbs +158 -0
- data/stdlib/uri/0/https.rbs +108 -0
- data/stdlib/uri/0/ldap.rbs +224 -0
- data/stdlib/uri/0/ldaps.rbs +108 -0
- data/stdlib/zlib/{zlib.rbs → 0/zlib.rbs} +0 -0
- data/steep/Gemfile.lock +13 -17
- metadata +105 -89
- data/stdlib/builtin/builtin.rbs +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5062396fb965f4d6f07ceee4f6b82ef22a12c20897d82c6615d6765d5bf43b7f
|
4
|
+
data.tar.gz: 8b30dd2d71e12d56501bafc2ab4ca1d604befbc3ef797f02234b6d6acc95ac71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec6b6090f0a93cbfbe2f4ffe5f5bbce253425f3f85a55dcabec2943f724a81c637c441820236aa1dcbff6104d1fe7d215e4cb38ac76c5f827677167e437761f5
|
7
|
+
data.tar.gz: 301d1c5a305dce97dfdd6d89c39a4deafcedc405535b13b1846b3d03af83a87747cc44ade7a0148b96af7d07d7a53b4eb7c8954344ae11d574f69ca81c3eb7a8
|
data/.github/workflows/ruby.yml
CHANGED
@@ -12,9 +12,9 @@ jobs:
|
|
12
12
|
strategy:
|
13
13
|
matrix:
|
14
14
|
container_tag:
|
15
|
-
- master-nightly-bionic
|
16
|
-
- 2.6
|
17
|
-
- 2.7
|
15
|
+
- master-nightly-bionic
|
16
|
+
- 2.6-bionic
|
17
|
+
- 2.7-bionic
|
18
18
|
job:
|
19
19
|
- test
|
20
20
|
- stdlib_test
|
@@ -23,6 +23,10 @@ jobs:
|
|
23
23
|
image: rubylang/ruby:${{ matrix.container_tag }}
|
24
24
|
steps:
|
25
25
|
- uses: actions/checkout@v1
|
26
|
+
- name: Install dependencies
|
27
|
+
run: |
|
28
|
+
apt-get update
|
29
|
+
apt-get install -y libdb-dev
|
26
30
|
- name: Install
|
27
31
|
run: |
|
28
32
|
ruby -v
|
@@ -31,4 +35,4 @@ jobs:
|
|
31
35
|
- name: Run test
|
32
36
|
run: |
|
33
37
|
bundle exec rake ${{ matrix.job }}
|
34
|
-
if: "!(matrix.job == 'stdlib_test' && contains(matrix.container_tag, '2.6
|
38
|
+
if: "!(matrix.job == 'stdlib_test' && contains(matrix.container_tag, '2.6'))"
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,38 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.16.0 (2020-11-05)
|
6
|
+
|
7
|
+
* Signature update for `DBM` ([#441](https://github.com/ruby/rbs/pull/441))
|
8
|
+
* RBS repository ([#405](https://github.com/ruby/rbs/pull/405))
|
9
|
+
* Support `alias` in `rbs prototype rb` ([#457](https://github.com/ruby/rbs/pull/457))
|
10
|
+
|
11
|
+
## 0.15.0 (2020-11-02)
|
12
|
+
|
13
|
+
* Signature updates for `Kernel`, `PStore`, `Enumerable`, and `Array` ([#450](https://github.com/ruby/rbs/pull/450), [#443](https://github.com/ruby/rbs/pull/443), [#438](https://github.com/ruby/rbs/pull/438), [#437](https://github.com/ruby/rbs/pull/437), [#433](https://github.com/ruby/rbs/pull/433), [#432](https://github.com/ruby/rbs/pull/432))
|
14
|
+
* Add helper interfaces ([#434](https://github.com/ruby/rbs/pull/434), [#428](https://github.com/ruby/rbs/pull/428))
|
15
|
+
* Change `bool` type semantics ([#456](https://github.com/ruby/rbs/pull/456))
|
16
|
+
* Support alias in `rbs prototype rb` ([#457](https://github.com/ruby/rbs/pull/457))
|
17
|
+
* Runtime testing improvements ([#455](https://github.com/ruby/rbs/pull/455), [#447](https://github.com/ruby/rbs/pull/447), [#444](https://github.com/ruby/rbs/pull/444), [#431](https://github.com/ruby/rbs/pull/431))
|
18
|
+
* Fix proc type parsing ([#451](https://github.com/ruby/rbs/pull/451))
|
19
|
+
* Fix type variable parsing ([#442](https://github.com/ruby/rbs/pull/442))
|
20
|
+
|
21
|
+
|
22
|
+
## 0.14.0 (2020-10-17)
|
23
|
+
|
24
|
+
* Allow keyword names ending with `?` and `!` ([#417](https://github.com/ruby/rbs/pull/417))
|
25
|
+
* Make `Range[T]` covariant ([#418](https://github.com/ruby/rbs/pull/418))
|
26
|
+
|
27
|
+
## 0.13.1 (2020-10-09)
|
28
|
+
|
29
|
+
* Fix test for CI of ruby/ruby ([#412](https://github.com/ruby/rbs/pull/412))
|
30
|
+
|
31
|
+
## 0.13.0 (2020-10-09)
|
32
|
+
|
33
|
+
* Signature updates for `URI` classes.
|
34
|
+
* Fix tests ([#410](https://github.com/ruby/rbs/pull/410))
|
35
|
+
* Add `--silent` option for `rbs validate` ([#411](https://github.com/ruby/rbs/pull/411))
|
36
|
+
|
5
37
|
## 0.12.2 (2020-09-17)
|
6
38
|
|
7
39
|
* Minor signature update for `pty`
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -74,7 +74,7 @@ $ rbs method Object then
|
|
74
74
|
|
75
75
|
## Library
|
76
76
|
|
77
|
-
There are two important concepts, _environment_ and _definition_.
|
77
|
+
There are two important concepts, _environment_ and _definition_.
|
78
78
|
|
79
79
|
An _environment_ is a dictionary that keeps track of all declarations. What is the declaration associated with `String` class? An _environment_ will give you the answer.
|
80
80
|
|
@@ -104,8 +104,14 @@ builder = RBS::DefinitionBuilder.new(env: environment)
|
|
104
104
|
|
105
105
|
# Definition of instance of String
|
106
106
|
instance = builder.build_instance(string)
|
107
|
-
|
107
|
+
|
108
|
+
# Print the types of `gsub` method:
|
108
109
|
puts instance.methods[:gsub].method_types.join("\n")
|
110
|
+
# Ouputs =>
|
111
|
+
# (::Regexp | ::string pattern, ::string replacement) -> ::String
|
112
|
+
# (::Regexp | ::string pattern, ::Hash[::String, ::String] hash) -> ::String
|
113
|
+
# (::Regexp | ::string pattern) { (::String match) -> ::_ToS } -> ::String
|
114
|
+
# (::Regexp | ::string pattern) -> ::Enumerator[::String, self]
|
109
115
|
|
110
116
|
# Definition of singleton of String
|
111
117
|
singleton = builder.build_singleton(string)
|
data/Rakefile
CHANGED
@@ -25,11 +25,18 @@ task :test_doc => :parser do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
task :validate => :parser do
|
28
|
-
sh "#{ruby} #{rbs} validate"
|
28
|
+
sh "#{ruby} #{rbs} validate --silent"
|
29
29
|
|
30
30
|
FileList["stdlib/*"].each do |path|
|
31
31
|
next if path =~ %r{stdlib/builtin}
|
32
|
-
|
32
|
+
|
33
|
+
lib = [File.basename(path).to_s]
|
34
|
+
|
35
|
+
if lib == ["bigdecimal-math"]
|
36
|
+
lib << "bigdecimal"
|
37
|
+
end
|
38
|
+
|
39
|
+
sh "#{ruby} #{rbs} #{lib.map {|l| "-r #{l}"}.join(" ")} validate --silent"
|
33
40
|
end
|
34
41
|
end
|
35
42
|
|
data/Steepfile
CHANGED
data/bin/annotate-with-rdoc
CHANGED
data/bin/setup
CHANGED
data/bin/test_runner.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
$LOAD_PATH << File.join(__dir__, "../lib")
|
4
4
|
|
5
|
+
require "set"
|
6
|
+
|
5
7
|
IS_RUBY_27 = Gem::Version.new(RUBY_VERSION).yield_self do |ruby_version|
|
6
8
|
Gem::Version.new('2.7.0') <= ruby_version &&
|
7
9
|
ruby_version <= Gem::Version.new('2.8.0')
|
@@ -11,6 +13,18 @@ unless IS_RUBY_27
|
|
11
13
|
STDERR.puts "⚠️⚠️⚠️⚠️ stdlib test assumes Ruby 2.7 but RUBY_VERSION==#{RUBY_VERSION} ⚠️⚠️⚠️⚠️"
|
12
14
|
end
|
13
15
|
|
16
|
+
KNOWN_FAILS = %w(dbm).map do |lib|
|
17
|
+
/cannot load such file -- #{lib}/
|
18
|
+
end
|
19
|
+
|
14
20
|
ARGV.each do |arg|
|
15
|
-
|
21
|
+
begin
|
22
|
+
load arg
|
23
|
+
rescue LoadError => exn
|
24
|
+
if KNOWN_FAILS.any? {|pat| pat =~ exn.message }
|
25
|
+
STDERR.puts "Loading #{arg} failed, ignoring it: #{exn.inspect}"
|
26
|
+
else
|
27
|
+
raise
|
28
|
+
end
|
29
|
+
end
|
16
30
|
end
|
@@ -234,7 +234,7 @@
|
|
234
234
|
# for pack.c
|
235
235
|
#
|
236
236
|
class Array[unchecked out Elem] < Object
|
237
|
-
include Enumerable[Elem,
|
237
|
+
include Enumerable[Elem, self]
|
238
238
|
|
239
239
|
# Returns a new array.
|
240
240
|
#
|
@@ -285,9 +285,9 @@ class Array[unchecked out Elem] < Object
|
|
285
285
|
# a # => [{"cat"=>"feline"}, {}]
|
286
286
|
#
|
287
287
|
def initialize: () -> void
|
288
|
-
| (Array[Elem] ary) -> void
|
288
|
+
| (::Array[Elem] ary) -> void
|
289
289
|
| (int size, ?Elem val) -> void
|
290
|
-
| (int size) { (Integer index) -> Elem } -> void
|
290
|
+
| (int size) { (::Integer index) -> Elem } -> void
|
291
291
|
|
292
292
|
# Returns a new array populated with the given objects.
|
293
293
|
#
|
@@ -324,7 +324,7 @@ class Array[unchecked out Elem] < Object
|
|
324
324
|
#
|
325
325
|
# See also Array#uniq.
|
326
326
|
#
|
327
|
-
def &: (Array[untyped] | _ToAry[untyped]) -> ::Array[Elem]
|
327
|
+
def &: (::Array[untyped] | _ToAry[untyped]) -> ::Array[Elem]
|
328
328
|
|
329
329
|
# Repetition --- With a String argument, equivalent to `ary.join(str)`.
|
330
330
|
#
|
@@ -334,8 +334,8 @@ class Array[unchecked out Elem] < Object
|
|
334
334
|
# [ 1, 2, 3 ] * 3 #=> [ 1, 2, 3, 1, 2, 3, 1, 2, 3 ]
|
335
335
|
# [ 1, 2, 3 ] * "," #=> "1,2,3"
|
336
336
|
#
|
337
|
-
def *: (string str) -> String
|
338
|
-
| (int int) -> Array[Elem]
|
337
|
+
def *: (string str) -> ::String
|
338
|
+
| (int int) -> ::Array[Elem]
|
339
339
|
|
340
340
|
# Concatenation --- Returns a new array built by concatenating the two arrays
|
341
341
|
# together to produce a third array.
|
@@ -388,7 +388,7 @@ class Array[unchecked out Elem] < Object
|
|
388
388
|
# a
|
389
389
|
# #=> [ 1, 2, "c", "d", [ 3, 4 ] ]
|
390
390
|
#
|
391
|
-
def <<: (Elem) ->
|
391
|
+
def <<: (Elem) -> self
|
392
392
|
|
393
393
|
# Comparison --- Returns an integer (`-1`, `0`, or `+1`) if this array is less
|
394
394
|
# than, equal to, or greater than `other_ary`.
|
@@ -413,7 +413,7 @@ class Array[unchecked out Elem] < Object
|
|
413
413
|
# [ 1, 2, 3, 4, 5, 6 ] <=> [ 1, 2 ] #=> +1
|
414
414
|
# [ 1, 2 ] <=> [ 1, :two ] #=> nil
|
415
415
|
#
|
416
|
-
def <=>: (untyped) -> Integer?
|
416
|
+
def <=>: (untyped) -> ::Integer?
|
417
417
|
|
418
418
|
# Equality --- Two arrays are equal if they contain the same number of elements
|
419
419
|
# and if each element is equal to (according to Object#==) the corresponding
|
@@ -452,7 +452,7 @@ class Array[unchecked out Elem] < Object
|
|
452
452
|
#
|
453
453
|
def []: (int index) -> Elem
|
454
454
|
| (int start, int length) -> ::Array[Elem]?
|
455
|
-
| (Range[Integer] range) -> ::Array[Elem]?
|
455
|
+
| (::Range[::Integer] range) -> ::Array[Elem]?
|
456
456
|
|
457
457
|
# Element Assignment --- Sets the element at `index`, or replaces a subarray
|
458
458
|
# from the `start` index for `length` elements, or replaces a subarray specified
|
@@ -484,17 +484,17 @@ class Array[unchecked out Elem] < Object
|
|
484
484
|
#
|
485
485
|
def []=: (int index, Elem obj) -> Elem
|
486
486
|
| (int start, int length, Elem obj) -> Elem
|
487
|
-
| (int start, int length, Array[Elem]) -> Array[Elem]
|
487
|
+
| (int start, int length, ::Array[Elem]) -> ::Array[Elem]
|
488
488
|
| (int start, int length, nil) -> nil
|
489
|
-
| (Range[Integer], Elem obj) -> Elem
|
490
|
-
| (Range[Integer], Array[Elem]) -> Array[Elem]
|
491
|
-
| (Range[Integer], nil) -> nil
|
489
|
+
| (::Range[::Integer], Elem obj) -> Elem
|
490
|
+
| (::Range[::Integer], ::Array[Elem]) -> ::Array[Elem]
|
491
|
+
| (::Range[::Integer], nil) -> nil
|
492
492
|
|
493
493
|
# See also Enumerable#all?
|
494
494
|
#
|
495
495
|
def all?: () -> bool
|
496
496
|
| (_Pattern[Elem] pattern) -> bool
|
497
|
-
| () { (Elem obj) ->
|
497
|
+
| () { (Elem obj) -> boolish } -> bool
|
498
498
|
|
499
499
|
# See also Enumerable#any?
|
500
500
|
#
|
@@ -517,7 +517,7 @@ class Array[unchecked out Elem] < Object
|
|
517
517
|
# a.assoc("letters") #=> [ "letters", "a", "b", "c" ]
|
518
518
|
# a.assoc("foo") #=> nil
|
519
519
|
#
|
520
|
-
def assoc: (untyped) -> Array[untyped]?
|
520
|
+
def assoc: (untyped) -> ::Array[untyped]?
|
521
521
|
|
522
522
|
# Returns the element at `index`. A negative index counts from the end of
|
523
523
|
# `self`. Returns `nil` if the index is out of range. See also Array#[].
|
@@ -577,7 +577,7 @@ class Array[unchecked out Elem] < Object
|
|
577
577
|
# actually picked up at each iteration.
|
578
578
|
#
|
579
579
|
def bsearch: () { (Elem) -> (true | false) } -> Elem?
|
580
|
-
| () { (Elem) -> Integer } -> Elem?
|
580
|
+
| () { (Elem) -> ::Integer } -> Elem?
|
581
581
|
|
582
582
|
# By using binary search, finds an index of a value from this array which meets
|
583
583
|
# the given condition in O(log n) where n is the size of the array.
|
@@ -587,8 +587,8 @@ class Array[unchecked out Elem] < Object
|
|
587
587
|
# that this method returns the index of the element instead of the element
|
588
588
|
# itself. For more details consult the documentation for #bsearch.
|
589
589
|
#
|
590
|
-
def bsearch_index: () { (Elem) -> (true | false) } -> Integer?
|
591
|
-
| () { (Elem) -> Integer } -> Integer?
|
590
|
+
def bsearch_index: () { (Elem) -> (true | false) } -> ::Integer?
|
591
|
+
| () { (Elem) -> ::Integer } -> ::Integer?
|
592
592
|
|
593
593
|
# Removes all elements from `self`.
|
594
594
|
#
|
@@ -610,8 +610,8 @@ class Array[unchecked out Elem] < Object
|
|
610
610
|
# a.map.with_index {|x, i| x * i} #=> ["", "b", "cc", "ddd"]
|
611
611
|
# a #=> ["a", "b", "c", "d"]
|
612
612
|
#
|
613
|
-
def collect: [U] () { (Elem item) -> U } -> Array[U]
|
614
|
-
| () -> Enumerator[Elem, Array[untyped]]
|
613
|
+
def collect: [U] () { (Elem item) -> U } -> ::Array[U]
|
614
|
+
| () -> ::Enumerator[Elem, ::Array[untyped]]
|
615
615
|
|
616
616
|
# Invokes the given block once for each element of `self`, replacing the element
|
617
617
|
# with the value returned by the block.
|
@@ -648,15 +648,15 @@ class Array[unchecked out Elem] < Object
|
|
648
648
|
# a.combination(0).to_a #=> [[]] # one combination of length 0
|
649
649
|
# a.combination(5).to_a #=> [] # no combinations of length 5
|
650
650
|
#
|
651
|
-
def combination: (int n) { (Array[Elem]) -> void } -> self
|
652
|
-
| (int n) -> Enumerator[Array[Elem], self]
|
651
|
+
def combination: (int n) { (::Array[Elem]) -> void } -> self
|
652
|
+
| (int n) -> ::Enumerator[::Array[Elem], self]
|
653
653
|
|
654
654
|
# Returns a copy of `self` with all `nil` elements removed.
|
655
655
|
#
|
656
656
|
# [ "a", nil, "b", nil, "c", nil ].compact
|
657
657
|
# #=> [ "a", "b", "c" ]
|
658
658
|
#
|
659
|
-
def compact: () -> Array[Elem]
|
659
|
+
def compact: () -> ::Array[Elem]
|
660
660
|
|
661
661
|
# Removes `nil` elements from the array.
|
662
662
|
#
|
@@ -665,7 +665,7 @@ class Array[unchecked out Elem] < Object
|
|
665
665
|
# [ "a", nil, "b", nil, "c" ].compact! #=> [ "a", "b", "c" ]
|
666
666
|
# [ "a", "b", "c" ].compact! #=> nil
|
667
667
|
#
|
668
|
-
def compact!: () ->
|
668
|
+
def compact!: () -> self?
|
669
669
|
|
670
670
|
# Appends the elements of `other_ary`s to `self`.
|
671
671
|
#
|
@@ -682,7 +682,7 @@ class Array[unchecked out Elem] < Object
|
|
682
682
|
#
|
683
683
|
# See also Array#+.
|
684
684
|
#
|
685
|
-
def concat: (
|
685
|
+
def concat: (*::Array[Elem] arrays) -> ::Array[Elem]
|
686
686
|
|
687
687
|
# Returns the number of elements.
|
688
688
|
#
|
@@ -697,9 +697,9 @@ class Array[unchecked out Elem] < Object
|
|
697
697
|
# ary.count(2) #=> 2
|
698
698
|
# ary.count {|x| x%2 == 0} #=> 3
|
699
699
|
#
|
700
|
-
def count: () -> Integer
|
701
|
-
| (untyped obj) -> Integer
|
702
|
-
| () { (Elem) ->
|
700
|
+
def count: () -> ::Integer
|
701
|
+
| (untyped obj) -> ::Integer
|
702
|
+
| () { (Elem) -> boolish } -> ::Integer
|
703
703
|
|
704
704
|
# Calls the given block for each element `n` times or forever if `nil` is given.
|
705
705
|
#
|
@@ -714,9 +714,9 @@ class Array[unchecked out Elem] < Object
|
|
714
714
|
# a.cycle(2) {|x| puts x} # print, a, b, c, a, b, c.
|
715
715
|
#
|
716
716
|
def cycle: (?int? n) { (Elem) -> void } -> nil
|
717
|
-
| (?int? n) -> Enumerator[Elem, nil]
|
717
|
+
| (?int? n) -> ::Enumerator[Elem, nil]
|
718
718
|
|
719
|
-
def deconstruct: () ->
|
719
|
+
def deconstruct: () -> self
|
720
720
|
|
721
721
|
# Deletes all items from `self` that are equal to `obj`.
|
722
722
|
#
|
@@ -759,8 +759,8 @@ class Array[unchecked out Elem] < Object
|
|
759
759
|
# scores = [ 97, 42, 75 ]
|
760
760
|
# scores.delete_if {|score| score < 80 } #=> [97]
|
761
761
|
#
|
762
|
-
def delete_if: () { (Elem item) ->
|
763
|
-
| () -> Enumerator[Elem, self]
|
762
|
+
def delete_if: () { (Elem item) -> boolish } -> self
|
763
|
+
| () -> ::Enumerator[Elem, self]
|
764
764
|
|
765
765
|
# Array Difference
|
766
766
|
#
|
@@ -786,7 +786,7 @@ class Array[unchecked out Elem] < Object
|
|
786
786
|
#
|
787
787
|
# See also Array#-.
|
788
788
|
#
|
789
|
-
def difference: (*::Array[untyped] arrays) -> Array[Elem]
|
789
|
+
def difference: (*::Array[untyped] arrays) -> ::Array[Elem]
|
790
790
|
|
791
791
|
# Extracts the nested value specified by the sequence of *idx* objects by
|
792
792
|
# calling `dig` at each step, returning `nil` if any intermediate step is `nil`.
|
@@ -824,8 +824,8 @@ class Array[unchecked out Elem] < Object
|
|
824
824
|
# a = [1, 2, 3, 4, 5, 0]
|
825
825
|
# a.drop_while {|i| i < 3 } #=> [3, 4, 5, 0]
|
826
826
|
#
|
827
|
-
def drop_while: () { (Elem obj) ->
|
828
|
-
| () -> ::Enumerator[Elem, Array[Elem]]
|
827
|
+
def drop_while: () { (Elem obj) -> boolish } -> ::Array[Elem]
|
828
|
+
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
829
829
|
|
830
830
|
# Calls the given block once for each element in `self`, passing that element as
|
831
831
|
# a parameter. Returns the array itself.
|
@@ -839,8 +839,8 @@ class Array[unchecked out Elem] < Object
|
|
839
839
|
#
|
840
840
|
# a -- b -- c --
|
841
841
|
#
|
842
|
-
def each: () -> ::Enumerator[Elem,
|
843
|
-
| () { (Elem item) -> void } ->
|
842
|
+
def each: () -> ::Enumerator[Elem, self]
|
843
|
+
| () { (Elem item) -> void } -> self
|
844
844
|
|
845
845
|
# Same as Array#each, but passes the `index` of the element instead of the
|
846
846
|
# element itself.
|
@@ -854,8 +854,8 @@ class Array[unchecked out Elem] < Object
|
|
854
854
|
#
|
855
855
|
# 0 -- 1 -- 2 --
|
856
856
|
#
|
857
|
-
def each_index: () { (Integer index) -> void } ->
|
858
|
-
| () -> ::Enumerator[Elem,
|
857
|
+
def each_index: () { (::Integer index) -> void } -> self
|
858
|
+
| () -> ::Enumerator[Elem, self]
|
859
859
|
|
860
860
|
# Returns `true` if `self` contains no elements.
|
861
861
|
#
|
@@ -887,7 +887,7 @@ class Array[unchecked out Elem] < Object
|
|
887
887
|
#
|
888
888
|
def fetch: (int index) -> Elem
|
889
889
|
| [T] (int index, T default) -> (Elem | T)
|
890
|
-
| [T] (
|
890
|
+
| [T] (int index) { (int index) -> T } -> (Elem | T)
|
891
891
|
|
892
892
|
# The first three forms set the selected elements of `self` (which may be the
|
893
893
|
# entire array) to `obj`.
|
@@ -911,9 +911,9 @@ class Array[unchecked out Elem] < Object
|
|
911
911
|
#
|
912
912
|
def fill: (Elem obj) -> self
|
913
913
|
| (Elem obj, int? start, ?int? length) -> self
|
914
|
-
| (Elem obj, Range[Integer] range) -> self
|
915
|
-
| (?int? start, ?int? length) { (Integer index) -> Elem } -> self
|
916
|
-
| (Range[Integer] range) { (Integer index) -> Elem } -> self
|
914
|
+
| (Elem obj, ::Range[::Integer] range) -> self
|
915
|
+
| (?int? start, ?int? length) { (::Integer index) -> Elem } -> self
|
916
|
+
| (::Range[::Integer] range) { (::Integer index) -> Elem } -> self
|
917
917
|
|
918
918
|
# Returns a new array containing all elements of `ary` for which the given
|
919
919
|
# `block` returns a true value.
|
@@ -929,8 +929,8 @@ class Array[unchecked out Elem] < Object
|
|
929
929
|
#
|
930
930
|
# Array#filter is an alias for Array#select.
|
931
931
|
#
|
932
|
-
def filter: () { (Elem item) ->
|
933
|
-
| () -> Enumerator[Elem, Array[Elem]]
|
932
|
+
def filter: () { (Elem item) -> boolish } -> ::Array[Elem]
|
933
|
+
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
934
934
|
|
935
935
|
# Invokes the given block passing in successive elements from `self`, deleting
|
936
936
|
# elements for which the block returns a `false` value.
|
@@ -945,8 +945,8 @@ class Array[unchecked out Elem] < Object
|
|
945
945
|
#
|
946
946
|
# Array#filter! is an alias for Array#select!.
|
947
947
|
#
|
948
|
-
def filter!: () { (Elem item) ->
|
949
|
-
| () -> Enumerator[Elem,
|
948
|
+
def filter!: () { (Elem item) -> boolish } -> self?
|
949
|
+
| () -> ::Enumerator[Elem, self?]
|
950
950
|
|
951
951
|
# Returns the *index* of the first object in `ary` such that the object is `==`
|
952
952
|
# to `obj`.
|
@@ -964,9 +964,9 @@ class Array[unchecked out Elem] < Object
|
|
964
964
|
# a.index("z") #=> nil
|
965
965
|
# a.index {|x| x == "b"} #=> 1
|
966
966
|
#
|
967
|
-
def find_index: (untyped obj) -> Integer?
|
968
|
-
| () { (Elem item) ->
|
969
|
-
| () -> Enumerator[Elem, Integer?]
|
967
|
+
def find_index: (untyped obj) -> ::Integer?
|
968
|
+
| () { (Elem item) -> boolish } -> ::Integer?
|
969
|
+
| () -> ::Enumerator[Elem, ::Integer?]
|
970
970
|
|
971
971
|
# Returns the first element, or the first `n` elements, of the array. If the
|
972
972
|
# array is empty, the first form returns `nil`, and the second form returns an
|
@@ -977,7 +977,7 @@ class Array[unchecked out Elem] < Object
|
|
977
977
|
# a.first(2) #=> ["q", "r"]
|
978
978
|
#
|
979
979
|
def first: () -> Elem?
|
980
|
-
| (int n) -> Array[Elem]
|
980
|
+
| (int n) -> ::Array[Elem]
|
981
981
|
|
982
982
|
# Returns a new array that is a one-dimensional flattening of `self`
|
983
983
|
# (recursively).
|
@@ -1010,7 +1010,7 @@ class Array[unchecked out Elem] < Object
|
|
1010
1010
|
# a = [ 1, 2, [3, [4, 5] ] ]
|
1011
1011
|
# a.flatten!(1) #=> [1, 2, 3, [4, 5]]
|
1012
1012
|
#
|
1013
|
-
def flatten!: (?int level) ->
|
1013
|
+
def flatten!: (?int level) -> self?
|
1014
1014
|
|
1015
1015
|
# Compute a hash-code for this array.
|
1016
1016
|
#
|
@@ -1019,7 +1019,7 @@ class Array[unchecked out Elem] < Object
|
|
1019
1019
|
#
|
1020
1020
|
# See also Object#hash.
|
1021
1021
|
#
|
1022
|
-
def hash: () -> Integer
|
1022
|
+
def hash: () -> ::Integer
|
1023
1023
|
|
1024
1024
|
# Returns `true` if the given `object` is present in `self` (that is, if any
|
1025
1025
|
# element `==` `object`), otherwise returns `false`.
|
@@ -1059,7 +1059,7 @@ class Array[unchecked out Elem] < Object
|
|
1059
1059
|
# a.insert(2, 99) #=> ["a", "b", 99, "c", "d"]
|
1060
1060
|
# a.insert(-2, 1, 2, 3) #=> ["a", "b", 99, "c", 1, 2, 3, "d"]
|
1061
1061
|
#
|
1062
|
-
def insert: (int index, *Elem obj) ->
|
1062
|
+
def insert: (int index, *Elem obj) -> self
|
1063
1063
|
|
1064
1064
|
# Creates a string representation of `self`, by calling #inspect on each
|
1065
1065
|
# element.
|
@@ -1079,7 +1079,7 @@ class Array[unchecked out Elem] < Object
|
|
1079
1079
|
#
|
1080
1080
|
# See also Array#&.
|
1081
1081
|
#
|
1082
|
-
def intersection: (
|
1082
|
+
def intersection: (*::Array[untyped] | _ToAry[untyped] other_ary) -> ::Array[Elem]
|
1083
1083
|
|
1084
1084
|
# Returns a string created by converting each element of the array to a string,
|
1085
1085
|
# separated by the given `separator`. If the `separator` is `nil`, it uses
|
@@ -1106,8 +1106,8 @@ class Array[unchecked out Elem] < Object
|
|
1106
1106
|
#
|
1107
1107
|
# See also Array#select!.
|
1108
1108
|
#
|
1109
|
-
def keep_if: () { (Elem item) ->
|
1110
|
-
| () -> Enumerator[Elem,
|
1109
|
+
def keep_if: () { (Elem item) -> boolish } -> self
|
1110
|
+
| () -> ::Enumerator[Elem, self]
|
1111
1111
|
|
1112
1112
|
# Returns the last element(s) of `self`. If the array is empty, the first form
|
1113
1113
|
# returns `nil`.
|
@@ -1119,14 +1119,14 @@ class Array[unchecked out Elem] < Object
|
|
1119
1119
|
# a.last(2) #=> ["y", "z"]
|
1120
1120
|
#
|
1121
1121
|
def last: () -> Elem?
|
1122
|
-
| (int n) -> Array[Elem]
|
1122
|
+
| (int n) -> ::Array[Elem]
|
1123
1123
|
|
1124
1124
|
# Returns the number of elements in `self`. May be zero.
|
1125
1125
|
#
|
1126
1126
|
# [ 1, 2, 3, 4, 5 ].length #=> 5
|
1127
1127
|
# [].length #=> 0
|
1128
1128
|
#
|
1129
|
-
def length: () -> Integer
|
1129
|
+
def length: () -> ::Integer
|
1130
1130
|
|
1131
1131
|
# Invokes the given block once for each element of `self`.
|
1132
1132
|
#
|
@@ -1172,9 +1172,9 @@ class Array[unchecked out Elem] < Object
|
|
1172
1172
|
# ary.max(2) {|a, b| a.length <=> b.length } #=> ["albatross", "horse"]
|
1173
1173
|
#
|
1174
1174
|
def max: () -> Elem?
|
1175
|
-
| () { (Elem a, Elem b) -> Integer? } -> Elem?
|
1176
|
-
| (int n) -> Array[Elem]
|
1177
|
-
| (int n) { (Elem a, Elem b) -> Integer? } -> Array[Elem]
|
1175
|
+
| () { (Elem a, Elem b) -> ::Integer? } -> Elem?
|
1176
|
+
| (int n) -> ::Array[Elem]
|
1177
|
+
| (int n) { (Elem a, Elem b) -> ::Integer? } -> ::Array[Elem]
|
1178
1178
|
|
1179
1179
|
# Returns the object in *ary* with the minimum value. The first form assumes all
|
1180
1180
|
# objects implement Comparable; the second uses the block to return *a <=> b*.
|
@@ -1198,7 +1198,7 @@ class Array[unchecked out Elem] < Object
|
|
1198
1198
|
# <=> b`.
|
1199
1199
|
#
|
1200
1200
|
def minmax: () -> [ Elem?, Elem? ]
|
1201
|
-
| () { (Elem a, Elem b) -> Integer? } -> [ Elem?, Elem? ]
|
1201
|
+
| () { (Elem a, Elem b) -> ::Integer? } -> [ Elem?, Elem? ]
|
1202
1202
|
|
1203
1203
|
# See also Enumerable#none?
|
1204
1204
|
#
|
@@ -1352,8 +1352,8 @@ class Array[unchecked out Elem] < Object
|
|
1352
1352
|
# a.permutation(0).to_a #=> [[]] # one permutation of length 0
|
1353
1353
|
# a.permutation(4).to_a #=> [] # no permutations of length 4
|
1354
1354
|
#
|
1355
|
-
def permutation: (?
|
1356
|
-
| (?
|
1355
|
+
def permutation: (?int n) -> ::Enumerator[::Array[Elem], ::Array[Elem]]
|
1356
|
+
| (?int n) { (::Array[Elem] p) -> void } -> ::Array[Elem]
|
1357
1357
|
|
1358
1358
|
# Removes the last element from `self` and returns it, or `nil` if the array is
|
1359
1359
|
# empty.
|
@@ -1368,7 +1368,7 @@ class Array[unchecked out Elem] < Object
|
|
1368
1368
|
# a #=> ["a"]
|
1369
1369
|
#
|
1370
1370
|
def pop: () -> Elem?
|
1371
|
-
| (int n) -> Array[Elem]
|
1371
|
+
| (int n) -> ::Array[Elem]
|
1372
1372
|
|
1373
1373
|
alias prepend unshift
|
1374
1374
|
|
@@ -1387,10 +1387,10 @@ class Array[unchecked out Elem] < Object
|
|
1387
1387
|
# [1,2].product() #=> [[1],[2]]
|
1388
1388
|
# [1,2].product([]) #=> []
|
1389
1389
|
#
|
1390
|
-
def product: () -> Array[[Elem]]
|
1391
|
-
| [X] (Array[X] other_ary) -> Array[[Elem, X]]
|
1392
|
-
| [X, Y] (Array[X] other_ary1, Array[Y] other_ary2) -> Array[[Elem, X, Y]]
|
1393
|
-
| [U] (*::Array[U] other_arys) -> Array[Array[Elem | U]]
|
1390
|
+
def product: () -> ::Array[[Elem]]
|
1391
|
+
| [X] (::Array[X] other_ary) -> ::Array[[Elem, X]]
|
1392
|
+
| [X, Y] (::Array[X] other_ary1, ::Array[Y] other_ary2) -> ::Array[[Elem, X, Y]]
|
1393
|
+
| [U] (*::Array[U] other_arys) -> ::Array[::Array[Elem | U]]
|
1394
1394
|
|
1395
1395
|
# Append --- Pushes the given object(s) on to the end of this array. This
|
1396
1396
|
# expression returns the array itself, so several appends may be chained
|
@@ -1402,7 +1402,7 @@ class Array[unchecked out Elem] < Object
|
|
1402
1402
|
# [1, 2, 3].push(4).push(5)
|
1403
1403
|
# #=> [1, 2, 3, 4, 5]
|
1404
1404
|
#
|
1405
|
-
def push: (*Elem obj) ->
|
1405
|
+
def push: (*Elem obj) -> self
|
1406
1406
|
|
1407
1407
|
# Searches through the array whose elements are also arrays.
|
1408
1408
|
#
|
@@ -1436,8 +1436,8 @@ class Array[unchecked out Elem] < Object
|
|
1436
1436
|
#
|
1437
1437
|
# If no block is given, an Enumerator is returned instead.
|
1438
1438
|
#
|
1439
|
-
def reject!: () { (Elem item) ->
|
1440
|
-
| () -> ::Enumerator[Elem,
|
1439
|
+
def reject!: () { (Elem item) -> boolish } -> self?
|
1440
|
+
| () -> ::Enumerator[Elem, self?]
|
1441
1441
|
|
1442
1442
|
# When invoked with a block, yields all repeated combinations of length `n` of
|
1443
1443
|
# elements from the array and then returns the array itself.
|
@@ -1459,8 +1459,8 @@ class Array[unchecked out Elem] < Object
|
|
1459
1459
|
# # [2,2,2,2],[2,2,2,3],[2,2,3,3],[2,3,3,3],[3,3,3,3]]
|
1460
1460
|
# a.repeated_combination(0).to_a #=> [[]] # one combination of length 0
|
1461
1461
|
#
|
1462
|
-
def repeated_combination: (int n) { (Array[Elem] c) -> void } -> self
|
1463
|
-
| (int n) -> Enumerator[Array[Elem], self]
|
1462
|
+
def repeated_combination: (int n) { (::Array[Elem] c) -> void } -> self
|
1463
|
+
| (int n) -> ::Enumerator[::Array[Elem], self]
|
1464
1464
|
|
1465
1465
|
# When invoked with a block, yield all repeated permutations of length `n` of
|
1466
1466
|
# the elements of the array, then return the array itself.
|
@@ -1479,8 +1479,8 @@ class Array[unchecked out Elem] < Object
|
|
1479
1479
|
# # [2,1,1],[2,1,2],[2,2,1],[2,2,2]]
|
1480
1480
|
# a.repeated_permutation(0).to_a #=> [[]] # one permutation of length 0
|
1481
1481
|
#
|
1482
|
-
def repeated_permutation: (int n) { (Array[Elem] p) -> void } -> self
|
1483
|
-
| (int n) -> Enumerator[Array[Elem], self]
|
1482
|
+
def repeated_permutation: (int n) { (::Array[Elem] p) -> void } -> self
|
1483
|
+
| (int n) -> ::Enumerator[::Array[Elem], self]
|
1484
1484
|
|
1485
1485
|
# Replaces the contents of `self` with the contents of `other_ary`, truncating
|
1486
1486
|
# or expanding if necessary.
|
@@ -1489,14 +1489,14 @@ class Array[unchecked out Elem] < Object
|
|
1489
1489
|
# a.replace([ "x", "y", "z" ]) #=> ["x", "y", "z"]
|
1490
1490
|
# a #=> ["x", "y", "z"]
|
1491
1491
|
#
|
1492
|
-
def replace: (Array[Elem]) -> self
|
1492
|
+
def replace: (::Array[Elem]) -> self
|
1493
1493
|
|
1494
1494
|
# Returns a new array containing `self`'s elements in reverse order.
|
1495
1495
|
#
|
1496
1496
|
# [ "a", "b", "c" ].reverse #=> ["c", "b", "a"]
|
1497
1497
|
# [ 1 ].reverse #=> [1]
|
1498
1498
|
#
|
1499
|
-
def reverse: () -> Array[Elem]
|
1499
|
+
def reverse: () -> ::Array[Elem]
|
1500
1500
|
|
1501
1501
|
# Reverses `self` in place.
|
1502
1502
|
#
|
@@ -1504,7 +1504,7 @@ class Array[unchecked out Elem] < Object
|
|
1504
1504
|
# a.reverse! #=> ["c", "b", "a"]
|
1505
1505
|
# a #=> ["c", "b", "a"]
|
1506
1506
|
#
|
1507
|
-
def reverse!: () -> Array[Elem]
|
1507
|
+
def reverse!: () -> ::Array[Elem]
|
1508
1508
|
|
1509
1509
|
# Same as Array#each, but traverses `self` in reverse order.
|
1510
1510
|
#
|
@@ -1515,8 +1515,8 @@ class Array[unchecked out Elem] < Object
|
|
1515
1515
|
#
|
1516
1516
|
# c b a
|
1517
1517
|
#
|
1518
|
-
def reverse_each: () { (Elem item) -> void } ->
|
1519
|
-
| () -> Enumerator[Elem,
|
1518
|
+
def reverse_each: () { (Elem item) -> void } -> self
|
1519
|
+
| () -> ::Enumerator[Elem, self]
|
1520
1520
|
|
1521
1521
|
# Returns the *index* of the last object in `self` `==` to `obj`.
|
1522
1522
|
#
|
@@ -1534,9 +1534,9 @@ class Array[unchecked out Elem] < Object
|
|
1534
1534
|
# a.rindex("z") #=> nil
|
1535
1535
|
# a.rindex {|x| x == "b"} #=> 3
|
1536
1536
|
#
|
1537
|
-
def rindex: (untyped obj) -> Integer?
|
1538
|
-
| () { (Elem item) ->
|
1539
|
-
| () -> Enumerator[Elem, Integer?]
|
1537
|
+
def rindex: (untyped obj) -> ::Integer?
|
1538
|
+
| () { (Elem item) -> boolish } -> ::Integer?
|
1539
|
+
| () -> ::Enumerator[Elem, ::Integer?]
|
1540
1540
|
|
1541
1541
|
# Returns a new array by rotating `self` so that the element at `count` is the
|
1542
1542
|
# first element of the new array.
|
@@ -1550,7 +1550,7 @@ class Array[unchecked out Elem] < Object
|
|
1550
1550
|
# a.rotate(2) #=> ["c", "d", "a", "b"]
|
1551
1551
|
# a.rotate(-3) #=> ["b", "c", "d", "a"]
|
1552
1552
|
#
|
1553
|
-
def rotate: (?int count) -> Array[Elem]
|
1553
|
+
def rotate: (?int count) -> ::Array[Elem]
|
1554
1554
|
|
1555
1555
|
# Rotates `self` in place so that the element at `count` comes first, and
|
1556
1556
|
# returns `self`.
|
@@ -1564,7 +1564,7 @@ class Array[unchecked out Elem] < Object
|
|
1564
1564
|
# a.rotate!(2) #=> ["d", "a", "b", "c"]
|
1565
1565
|
# a.rotate!(-3) #=> ["a", "b", "c", "d"]
|
1566
1566
|
#
|
1567
|
-
def rotate!: (?int count) ->
|
1567
|
+
def rotate!: (?int count) -> self
|
1568
1568
|
|
1569
1569
|
# Choose a random element or `n` random elements from the array.
|
1570
1570
|
#
|
@@ -1601,8 +1601,8 @@ class Array[unchecked out Elem] < Object
|
|
1601
1601
|
#
|
1602
1602
|
# Array#filter is an alias for Array#select.
|
1603
1603
|
#
|
1604
|
-
def select: () { (Elem item) ->
|
1605
|
-
| () -> Enumerator[Elem, Array[Elem]]
|
1604
|
+
def select: () { (Elem item) -> boolish } -> ::Array[Elem]
|
1605
|
+
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
1606
1606
|
|
1607
1607
|
# Invokes the given block passing in successive elements from `self`, deleting
|
1608
1608
|
# elements for which the block returns a `false` value.
|
@@ -1617,8 +1617,8 @@ class Array[unchecked out Elem] < Object
|
|
1617
1617
|
#
|
1618
1618
|
# Array#filter! is an alias for Array#select!.
|
1619
1619
|
#
|
1620
|
-
def select!: () { (Elem item) ->
|
1621
|
-
| () -> ::Enumerator[Elem,
|
1620
|
+
def select!: () { (Elem item) -> boolish } -> self?
|
1621
|
+
| () -> ::Enumerator[Elem, self?]
|
1622
1622
|
|
1623
1623
|
# Removes the first element of `self` and returns it (shifting all other
|
1624
1624
|
# elements down by one). Returns `nil` if the array is empty.
|
@@ -1637,7 +1637,7 @@ class Array[unchecked out Elem] < Object
|
|
1637
1637
|
# args #=> ["filename"]
|
1638
1638
|
#
|
1639
1639
|
def shift: () -> Elem?
|
1640
|
-
| (?int n) -> Array[Elem]
|
1640
|
+
| (?int n) -> ::Array[Elem]
|
1641
1641
|
|
1642
1642
|
# Returns a new array with elements of `self` shuffled.
|
1643
1643
|
#
|
@@ -1649,7 +1649,7 @@ class Array[unchecked out Elem] < Object
|
|
1649
1649
|
#
|
1650
1650
|
# a.shuffle(random: Random.new(1)) #=> [1, 3, 2]
|
1651
1651
|
#
|
1652
|
-
def shuffle: (?random: Random rng) -> Array[Elem]
|
1652
|
+
def shuffle: (?random: Random rng) -> ::Array[Elem]
|
1653
1653
|
|
1654
1654
|
# Shuffles elements in `self` in place.
|
1655
1655
|
#
|
@@ -1661,7 +1661,7 @@ class Array[unchecked out Elem] < Object
|
|
1661
1661
|
#
|
1662
1662
|
# a.shuffle!(random: Random.new(1)) #=> [1, 3, 2]
|
1663
1663
|
#
|
1664
|
-
def shuffle!: (?random: Random rng) ->
|
1664
|
+
def shuffle!: (?random: Random rng) -> self
|
1665
1665
|
|
1666
1666
|
alias size length
|
1667
1667
|
|
@@ -1691,8 +1691,8 @@ class Array[unchecked out Elem] < Object
|
|
1691
1691
|
# a[5..10] #=> []
|
1692
1692
|
#
|
1693
1693
|
def slice: (int index) -> Elem?
|
1694
|
-
| (int start, int length) -> Array[Elem]?
|
1695
|
-
| (Range[Integer] range) -> Array[Elem]?
|
1694
|
+
| (int start, int length) -> ::Array[Elem]?
|
1695
|
+
| (::Range[::Integer] range) -> ::Array[Elem]?
|
1696
1696
|
|
1697
1697
|
# Deletes the element(s) given by an `index` (optionally up to `length`
|
1698
1698
|
# elements) or by a `range`.
|
@@ -1709,8 +1709,8 @@ class Array[unchecked out Elem] < Object
|
|
1709
1709
|
# a #=> ["a"]
|
1710
1710
|
#
|
1711
1711
|
def slice!: (int index) -> Elem?
|
1712
|
-
| (int start, int length) -> Array[Elem]?
|
1713
|
-
| (Range[Integer] range) -> Array[Elem]?
|
1712
|
+
| (int start, int length) -> ::Array[Elem]?
|
1713
|
+
| (::Range[::Integer] range) -> ::Array[Elem]?
|
1714
1714
|
|
1715
1715
|
# Returns a new array created by sorting `self`.
|
1716
1716
|
#
|
@@ -1736,7 +1736,7 @@ class Array[unchecked out Elem] < Object
|
|
1736
1736
|
# See also Enumerable#sort_by.
|
1737
1737
|
#
|
1738
1738
|
def sort: () -> ::Array[Elem]
|
1739
|
-
| () { (Elem a, Elem b) -> Integer? } -> Array[Elem]
|
1739
|
+
| () { (Elem a, Elem b) -> ::Integer? } -> ::Array[Elem]
|
1740
1740
|
|
1741
1741
|
# Sorts `self` in place.
|
1742
1742
|
#
|
@@ -1756,8 +1756,8 @@ class Array[unchecked out Elem] < Object
|
|
1756
1756
|
#
|
1757
1757
|
# See also Enumerable#sort_by.
|
1758
1758
|
#
|
1759
|
-
def sort!: () ->
|
1760
|
-
| () { (Elem a, Elem b) -> Integer? } ->
|
1759
|
+
def sort!: () -> self
|
1760
|
+
| () { (Elem a, Elem b) -> ::Integer? } -> self
|
1761
1761
|
|
1762
1762
|
# Sorts `self` in place using a set of keys generated by mapping the values in
|
1763
1763
|
# `self` through the given block.
|
@@ -1769,8 +1769,8 @@ class Array[unchecked out Elem] < Object
|
|
1769
1769
|
#
|
1770
1770
|
# See also Enumerable#sort_by.
|
1771
1771
|
#
|
1772
|
-
def sort_by!: [U] () { (Elem obj) -> U } -> Array[Elem]
|
1773
|
-
| () -> Enumerator[Elem, Array[Elem]]
|
1772
|
+
def sort_by!: [U] () { (Elem obj) -> U } -> ::Array[Elem]
|
1773
|
+
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
1774
1774
|
|
1775
1775
|
# Returns the sum of elements. For example, [e1, e2, e3].sum returns init + e1 +
|
1776
1776
|
# e2 + e3.
|
@@ -1828,14 +1828,14 @@ class Array[unchecked out Elem] < Object
|
|
1828
1828
|
# a = [1, 2, 3, 4, 5, 0]
|
1829
1829
|
# a.take_while {|i| i < 3} #=> [1, 2]
|
1830
1830
|
#
|
1831
|
-
def take_while: () { (Elem obj) ->
|
1832
|
-
| () -> Enumerator[Elem, Array[Elem]]
|
1831
|
+
def take_while: () { (Elem obj) -> boolish } -> ::Array[Elem]
|
1832
|
+
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
1833
1833
|
|
1834
1834
|
# Returns `self`.
|
1835
1835
|
#
|
1836
1836
|
# If called on a subclass of Array, converts the receiver to an Array object.
|
1837
1837
|
#
|
1838
|
-
def to_a: () -> Array[Elem]
|
1838
|
+
def to_a: () -> ::Array[Elem]
|
1839
1839
|
|
1840
1840
|
# Returns `self`.
|
1841
1841
|
#
|
@@ -1864,7 +1864,7 @@ class Array[unchecked out Elem] < Object
|
|
1864
1864
|
#
|
1865
1865
|
# If the length of the subarrays don't match, an IndexError is raised.
|
1866
1866
|
#
|
1867
|
-
def transpose: () -> Array[Array[untyped]]
|
1867
|
+
def transpose: () -> ::Array[::Array[untyped]]
|
1868
1868
|
|
1869
1869
|
# Set Union --- Returns a new array by joining `other_ary`s with `self`,
|
1870
1870
|
# excluding any duplicates and preserving the order from the given arrays.
|
@@ -1877,7 +1877,7 @@ class Array[unchecked out Elem] < Object
|
|
1877
1877
|
#
|
1878
1878
|
# See also Array#|.
|
1879
1879
|
#
|
1880
|
-
def union: [T] (
|
1880
|
+
def union: [T] (*::Array[T] other_arys) -> ::Array[T | Elem]
|
1881
1881
|
|
1882
1882
|
# Returns a new array by removing duplicate values in `self`.
|
1883
1883
|
#
|
@@ -1893,8 +1893,8 @@ class Array[unchecked out Elem] < Object
|
|
1893
1893
|
# b = [["student","sam"], ["student","george"], ["teacher","matz"]]
|
1894
1894
|
# b.uniq {|s| s.first} # => [["student", "sam"], ["teacher", "matz"]]
|
1895
1895
|
#
|
1896
|
-
def uniq: () -> Array[Elem]
|
1897
|
-
| () { (Elem item) -> untyped } -> Array[Elem]
|
1896
|
+
def uniq: () -> ::Array[Elem]
|
1897
|
+
| () { (Elem item) -> untyped } -> ::Array[Elem]
|
1898
1898
|
|
1899
1899
|
# Removes duplicate elements from `self`.
|
1900
1900
|
#
|
@@ -1915,8 +1915,8 @@ class Array[unchecked out Elem] < Object
|
|
1915
1915
|
# c = [["student","sam"], ["student","george"], ["teacher","matz"]]
|
1916
1916
|
# c.uniq! {|s| s.first} # => [["student", "sam"], ["teacher", "matz"]]
|
1917
1917
|
#
|
1918
|
-
def uniq!: () ->
|
1919
|
-
| () { (Elem) -> untyped } ->
|
1918
|
+
def uniq!: () -> self?
|
1919
|
+
| () { (Elem) -> untyped } -> self?
|
1920
1920
|
|
1921
1921
|
# Prepends objects to the front of `self`, moving other elements upwards. See
|
1922
1922
|
# also Array#shift for the opposite effect.
|
@@ -1925,7 +1925,7 @@ class Array[unchecked out Elem] < Object
|
|
1925
1925
|
# a.unshift("a") #=> ["a", "b", "c", "d"]
|
1926
1926
|
# a.unshift(1, 2) #=> [ 1, 2, "a", "b", "c", "d"]
|
1927
1927
|
#
|
1928
|
-
def unshift: (*Elem obj) ->
|
1928
|
+
def unshift: (*Elem obj) -> self
|
1929
1929
|
|
1930
1930
|
# Returns an array containing the elements in `self` corresponding to the given
|
1931
1931
|
# `selector`(s).
|
@@ -1940,7 +1940,7 @@ class Array[unchecked out Elem] < Object
|
|
1940
1940
|
# a.values_at(-1, -2, -2, -7) # => ["f", "e", "e", nil]
|
1941
1941
|
# a.values_at(4..6, 3...6) # => ["e", "f", nil, "d", "e", "f"]
|
1942
1942
|
#
|
1943
|
-
def values_at: (*int | Range[Integer] selector) -> Array[Elem?]
|
1943
|
+
def values_at: (*int | ::Range[::Integer] selector) -> ::Array[Elem?]
|
1944
1944
|
|
1945
1945
|
# Converts any arguments to arrays, then merges elements of `self` with
|
1946
1946
|
# corresponding elements from each argument.
|
@@ -1960,10 +1960,10 @@ class Array[unchecked out Elem] < Object
|
|
1960
1960
|
# [1, 2].zip(a, b) #=> [[1, 4, 7], [2, 5, 8]]
|
1961
1961
|
# a.zip([1, 2], [8]) #=> [[4, 1, 8], [5, 2, nil], [6, nil, nil]]
|
1962
1962
|
#
|
1963
|
-
def zip: [U] (Array[U] arg) -> Array[[ Elem, U? ]]
|
1964
|
-
| (Array[untyped] arg,
|
1965
|
-
| [U] (Array[U] arg) { ([Elem, U?]) -> void } -> void
|
1966
|
-
| (Array[untyped] arg,
|
1963
|
+
def zip: [U] (::Array[U] arg) -> ::Array[[ Elem, U? ]]
|
1964
|
+
| (::Array[untyped] arg, *::Array[untyped] args) -> ::Array[::Array[untyped]]
|
1965
|
+
| [U] (::Array[U] arg) { ([Elem, U?]) -> void } -> void
|
1966
|
+
| (::Array[untyped] arg, *::Array[untyped] args) { (::Array[untyped]) -> void } -> void
|
1967
1967
|
|
1968
1968
|
# Set Union --- Returns a new array by joining `ary` with `other_ary`, excluding
|
1969
1969
|
# any duplicates and preserving the order from the given arrays.
|
@@ -1975,7 +1975,7 @@ class Array[unchecked out Elem] < Object
|
|
1975
1975
|
#
|
1976
1976
|
# See also Array#union.
|
1977
1977
|
#
|
1978
|
-
def |: [T] (Array[T] other_ary) -> Array[Elem | T]
|
1978
|
+
def |: [T] (::Array[T] other_ary) -> ::Array[Elem | T]
|
1979
1979
|
|
1980
1980
|
private
|
1981
1981
|
|
@@ -1989,8 +1989,12 @@ class Array[unchecked out Elem] < Object
|
|
1989
1989
|
def initialize_copy: (self other_ary) -> void
|
1990
1990
|
end
|
1991
1991
|
|
1992
|
+
interface _ToA[T]
|
1993
|
+
def to_a: () -> Array[T]
|
1994
|
+
end
|
1995
|
+
|
1992
1996
|
interface _ToAry[T]
|
1993
|
-
def to_ary: () -> Array[T]
|
1997
|
+
def to_ary: () -> ::Array[T]
|
1994
1998
|
end
|
1995
1999
|
|
1996
2000
|
interface Array::_Pattern[T]
|