rbs 4.1.0.pre.2 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.dockerignore +37 -0
- data/.github/workflows/bundle-update.yml +1 -1
- data/.github/workflows/c-check.yml +11 -6
- data/.github/workflows/comments.yml +2 -2
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/jruby.yml +15 -3
- data/.github/workflows/milestone.yml +9 -1
- data/.github/workflows/ruby.yml +4 -4
- data/.github/workflows/rust.yml +10 -8
- data/.github/workflows/truffleruby.yml +1 -1
- data/.github/workflows/typecheck.yml +2 -2
- data/.github/workflows/wasm.yml +4 -2
- data/.github/workflows/windows.yml +2 -2
- data/.gitignore +3 -2
- data/CHANGELOG.md +88 -0
- data/Dockerfile.jruby +53 -0
- data/Rakefile +16 -29
- data/Steepfile +2 -0
- data/core/array.rbs +228 -165
- data/core/float.rbs +0 -24
- data/core/match_data.rbs +1 -1
- data/core/pathname.rbs +0 -10
- data/core/ractor.rbs +0 -10
- data/core/rubygems/errors.rbs +4 -1
- data/core/rubygems/requirement.rbs +0 -10
- data/core/rubygems/rubygems.rbs +4 -1
- data/core/rubygems/specification.rbs +8 -0
- data/core/rubygems/version.rbs +0 -160
- data/core/thread.rbs +3 -8
- data/docs/CONTRIBUTING.md +1 -1
- data/docs/release.md +69 -0
- data/ext/rbs_extension/ast_translation.c +2 -2
- data/ext/rbs_extension/legacy_location.c +11 -6
- data/lib/rbs/parser_aux.rb +4 -2
- data/lib/rbs/prototype/rbi.rb +193 -25
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/wasm/runtime.rb +7 -28
- data/lib/rbs_jars.rb +39 -0
- data/lib/rdoc_plugin/parser.rb +5 -0
- data/rbs.gemspec +16 -3
- data/sig/prototype/rbi.rbs +33 -4
- data/src/lexer.c +97 -93
- data/src/lexer.re +1 -1
- data/src/lexstate.c +6 -2
- data/src/util/rbs_allocator.c +13 -4
- data/stdlib/delegate/0/delegator.rbs +2 -1
- data/stdlib/digest/0/digest.rbs +10 -4
- data/stdlib/erb/0/erb.rbs +1 -1
- data/stdlib/ipaddr/0/ipaddr.rbs +0 -5
- data/stdlib/monitor/0/monitor.rbs +2 -2
- data/stdlib/openssl/0/openssl.rbs +39 -33
- data/stdlib/tempfile/0/manifest.yaml +3 -0
- data/stdlib/timeout/0/timeout.rbs +0 -5
- data/stdlib/uri/0/generic.rbs +0 -5
- data/stdlib/zlib/0/zstream.rbs +0 -1
- data/wasm/README.md +4 -3
- data/wasm/rbs_wasm.c +12 -0
- metadata +6 -1
data/core/array.rbs
CHANGED
|
@@ -546,9 +546,15 @@
|
|
|
546
546
|
# given block.
|
|
547
547
|
#
|
|
548
548
|
%a{annotate:rdoc:source:from=array.c}
|
|
549
|
-
class Array[unchecked out E]
|
|
549
|
+
class Array[unchecked out E]
|
|
550
550
|
include Enumerable[E]
|
|
551
551
|
|
|
552
|
+
# Interface for random number generations; used with `Array#shuffle`, `Array#shuffle!`, and `Array#sample`.
|
|
553
|
+
interface _Rand
|
|
554
|
+
# Generate a random number up to, but excluding, `max`
|
|
555
|
+
def rand: (Integer max) -> int
|
|
556
|
+
end
|
|
557
|
+
|
|
552
558
|
# <!--
|
|
553
559
|
# rdoc-file=array.c
|
|
554
560
|
# - Array.new -> new_empty_array
|
|
@@ -604,9 +610,9 @@ class Array[unchecked out E] < Object
|
|
|
604
610
|
# Array](rdoc-ref:Array@Methods+for+Creating+an+Array).
|
|
605
611
|
#
|
|
606
612
|
def initialize: () -> void
|
|
607
|
-
| (
|
|
608
|
-
| (int size, ?E
|
|
609
|
-
| (int size) { (
|
|
613
|
+
| (array[E] array) -> void
|
|
614
|
+
| (int size, ?E default_value) -> void
|
|
615
|
+
| (int size) { (Integer index) -> E } -> void
|
|
610
616
|
|
|
611
617
|
# <!--
|
|
612
618
|
# rdoc-file=array.c
|
|
@@ -621,7 +627,7 @@ class Array[unchecked out E] < Object
|
|
|
621
627
|
# Related: see [Methods for Creating an
|
|
622
628
|
# Array](rdoc-ref:Array@Methods+for+Creating+an+Array).
|
|
623
629
|
#
|
|
624
|
-
def self.[]: [U] (*U) ->
|
|
630
|
+
def self.[]: [U] (*U) -> Array[U] # this technically returns a subclass, but `instance(self)` isn't a thing
|
|
625
631
|
|
|
626
632
|
# <!--
|
|
627
633
|
# rdoc-file=array.c
|
|
@@ -640,7 +646,9 @@ class Array[unchecked out E] < Object
|
|
|
640
646
|
# Related: see [Methods for Creating an
|
|
641
647
|
# Array](rdoc-ref:Array@Methods+for+Creating+an+Array).
|
|
642
648
|
#
|
|
643
|
-
def self.try_convert: [U] (
|
|
649
|
+
def self.try_convert: [A < Array[U], U] (A array) -> A
|
|
650
|
+
| [U] (array[U] ary) -> Array[U]?
|
|
651
|
+
| (untyped) -> Array[untyped]?
|
|
644
652
|
|
|
645
653
|
# <!--
|
|
646
654
|
# rdoc-file=array.c
|
|
@@ -664,7 +672,7 @@ class Array[unchecked out E] < Object
|
|
|
664
672
|
#
|
|
665
673
|
# Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
|
|
666
674
|
#
|
|
667
|
-
def &: (
|
|
675
|
+
def &: (array[untyped] other_array) -> Array[E] # where E: _Eql?[T]
|
|
668
676
|
|
|
669
677
|
# <!--
|
|
670
678
|
# rdoc-file=array.c
|
|
@@ -682,8 +690,8 @@ class Array[unchecked out E] < Object
|
|
|
682
690
|
#
|
|
683
691
|
# [0, [0, 1], {foo: 0}] * ', ' # => "0, 0, 1, {foo: 0}"
|
|
684
692
|
#
|
|
685
|
-
def *: (string
|
|
686
|
-
| (int
|
|
693
|
+
def *: (string string_separator) -> String # where E: _ToS
|
|
694
|
+
| (int n) -> Array[E] # where E: _ToS
|
|
687
695
|
|
|
688
696
|
# <!--
|
|
689
697
|
# rdoc-file=array.c
|
|
@@ -697,7 +705,7 @@ class Array[unchecked out E] < Object
|
|
|
697
705
|
#
|
|
698
706
|
# Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
|
|
699
707
|
#
|
|
700
|
-
def +: [U] (
|
|
708
|
+
def +: [U] (array[U] other_array) -> Array[E | U]
|
|
701
709
|
|
|
702
710
|
# <!--
|
|
703
711
|
# rdoc-file=array.c
|
|
@@ -715,7 +723,7 @@ class Array[unchecked out E] < Object
|
|
|
715
723
|
#
|
|
716
724
|
# Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
|
|
717
725
|
#
|
|
718
|
-
def -: (
|
|
726
|
+
def -: (array[untyped] other_array) -> Array[E] # where E: _Eql?[T]
|
|
719
727
|
|
|
720
728
|
# <!--
|
|
721
729
|
# rdoc-file=array.c
|
|
@@ -731,7 +739,7 @@ class Array[unchecked out E] < Object
|
|
|
731
739
|
#
|
|
732
740
|
# Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
|
|
733
741
|
#
|
|
734
|
-
def <<: (E) -> self
|
|
742
|
+
def <<: (E object) -> self
|
|
735
743
|
|
|
736
744
|
# <!--
|
|
737
745
|
# rdoc-file=array.c
|
|
@@ -770,7 +778,7 @@ class Array[unchecked out E] < Object
|
|
|
770
778
|
#
|
|
771
779
|
# Related: see [Methods for Comparing](rdoc-ref:Array@Methods+for+Comparing).
|
|
772
780
|
#
|
|
773
|
-
def <=>: (untyped) -> ::Integer
|
|
781
|
+
def <=>: (untyped) -> Integer? # Until we can do `where E: RBS::Ops::_Compare`, this is always going to return `Integer?`
|
|
774
782
|
|
|
775
783
|
# <!--
|
|
776
784
|
# rdoc-file=array.c
|
|
@@ -919,8 +927,8 @@ class Array[unchecked out E] < Object
|
|
|
919
927
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
920
928
|
#
|
|
921
929
|
def []: %a{implicitly-returns-nil} (int index) -> E
|
|
922
|
-
| (int start, int length) ->
|
|
923
|
-
| (
|
|
930
|
+
| (int start, int length) -> Array[E]?
|
|
931
|
+
| (range[int] range) -> Array[E]?
|
|
924
932
|
|
|
925
933
|
# <!--
|
|
926
934
|
# rdoc-file=array.c
|
|
@@ -1068,13 +1076,11 @@ class Array[unchecked out E] < Object
|
|
|
1068
1076
|
#
|
|
1069
1077
|
# Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
|
|
1070
1078
|
#
|
|
1071
|
-
def []=: (int index, E
|
|
1072
|
-
|
|
|
1073
|
-
| (int
|
|
1074
|
-
| (int start, int length,
|
|
1075
|
-
| (
|
|
1076
|
-
| (::Range[::Integer?], ::Array[E]) -> ::Array[E]
|
|
1077
|
-
| (::Range[::Integer?], nil) -> nil
|
|
1079
|
+
def []=: (int index, E object) -> E
|
|
1080
|
+
| [T < _ToAry[E]] (range[int?] range, T array) -> T
|
|
1081
|
+
| (range[int?] range, E object) -> E
|
|
1082
|
+
| [T < _ToAry[E]] (int start, int length, T array) -> T
|
|
1083
|
+
| (int start, int length, E object) -> E
|
|
1078
1084
|
|
|
1079
1085
|
# <!--
|
|
1080
1086
|
# rdoc-file=array.c
|
|
@@ -1114,8 +1120,8 @@ class Array[unchecked out E] < Object
|
|
|
1114
1120
|
# Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
|
|
1115
1121
|
#
|
|
1116
1122
|
def all?: () -> bool
|
|
1117
|
-
| (
|
|
1118
|
-
| () { (E
|
|
1123
|
+
| (RBS::Ops::_CaseEqual[E, boolish] pattern) -> bool
|
|
1124
|
+
| () { (E element) -> boolish } -> bool
|
|
1119
1125
|
|
|
1120
1126
|
# <!--
|
|
1121
1127
|
# rdoc-file=array.c
|
|
@@ -1155,7 +1161,9 @@ class Array[unchecked out E] < Object
|
|
|
1155
1161
|
#
|
|
1156
1162
|
# Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
|
|
1157
1163
|
#
|
|
1158
|
-
|
|
1164
|
+
def any?: () -> bool
|
|
1165
|
+
| (RBS::Ops::_CaseEqual[E, boolish] pattern) -> bool
|
|
1166
|
+
| () { (E element) -> boolish } -> bool
|
|
1159
1167
|
|
|
1160
1168
|
# <!-- rdoc-file=array.c -->
|
|
1161
1169
|
# Appends each argument in `objects` to `self`; returns `self`:
|
|
@@ -1187,7 +1195,7 @@ class Array[unchecked out E] < Object
|
|
|
1187
1195
|
# Related: Array#rassoc; see also [Methods for
|
|
1188
1196
|
# Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
1189
1197
|
#
|
|
1190
|
-
def assoc: (untyped) ->
|
|
1198
|
+
def assoc: (untyped object) -> Array[untyped]? # where E: _ToAry[X], object: _Equal
|
|
1191
1199
|
|
|
1192
1200
|
# <!--
|
|
1193
1201
|
# rdoc-file=array.c
|
|
@@ -1225,9 +1233,9 @@ class Array[unchecked out E] < Object
|
|
|
1225
1233
|
#
|
|
1226
1234
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
1227
1235
|
#
|
|
1228
|
-
def bsearch: ()
|
|
1229
|
-
| () { (E) ->
|
|
1230
|
-
| ()
|
|
1236
|
+
def bsearch: () { (E element) -> bool? } -> E?
|
|
1237
|
+
| () { (E element) -> Numeric? } -> E?
|
|
1238
|
+
| () -> Enumerator[E, E?]
|
|
1231
1239
|
|
|
1232
1240
|
# <!--
|
|
1233
1241
|
# rdoc-file=array.c
|
|
@@ -1241,8 +1249,9 @@ class Array[unchecked out E] < Object
|
|
|
1241
1249
|
#
|
|
1242
1250
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
1243
1251
|
#
|
|
1244
|
-
def bsearch_index: () { (E) ->
|
|
1245
|
-
| () { (E) ->
|
|
1252
|
+
def bsearch_index: () { (E element) -> bool? } -> Integer?
|
|
1253
|
+
| () { (E element) -> Numeric? } -> Integer?
|
|
1254
|
+
| () -> Enumerator[E, Integer?]
|
|
1246
1255
|
|
|
1247
1256
|
# <!--
|
|
1248
1257
|
# rdoc-file=array.c
|
|
@@ -1276,8 +1285,8 @@ class Array[unchecked out E] < Object
|
|
|
1276
1285
|
# Related: #collect!; see also [Methods for
|
|
1277
1286
|
# Converting](rdoc-ref:Array@Methods+for+Converting).
|
|
1278
1287
|
#
|
|
1279
|
-
def collect: [
|
|
1280
|
-
| () ->
|
|
1288
|
+
def collect: [T] () { (E item) -> T } -> Array[T]
|
|
1289
|
+
| () -> Enumerator[E, Array[untyped]]
|
|
1281
1290
|
|
|
1282
1291
|
# <!--
|
|
1283
1292
|
# rdoc-file=array.c
|
|
@@ -1297,8 +1306,8 @@ class Array[unchecked out E] < Object
|
|
|
1297
1306
|
# Related: #collect; see also [Methods for
|
|
1298
1307
|
# Converting](rdoc-ref:Array@Methods+for+Converting).
|
|
1299
1308
|
#
|
|
1300
|
-
def collect!: () { (E
|
|
1301
|
-
| () ->
|
|
1309
|
+
def collect!: () { (E element) -> E } -> self
|
|
1310
|
+
| () -> Enumerator[E, self]
|
|
1302
1311
|
|
|
1303
1312
|
# <!--
|
|
1304
1313
|
# rdoc-file=array.c
|
|
@@ -1342,8 +1351,8 @@ class Array[unchecked out E] < Object
|
|
|
1342
1351
|
# Related: Array#permutation; see also [Methods for
|
|
1343
1352
|
# Iterating](rdoc-ref:Array@Methods+for+Iterating).
|
|
1344
1353
|
#
|
|
1345
|
-
def combination: (int
|
|
1346
|
-
| (int
|
|
1354
|
+
def combination: (int count) { (Array[E] combination) -> void } -> self
|
|
1355
|
+
| (int count) -> Enumerator[Array[E], self]
|
|
1347
1356
|
|
|
1348
1357
|
# <!--
|
|
1349
1358
|
# rdoc-file=array.c
|
|
@@ -1358,7 +1367,7 @@ class Array[unchecked out E] < Object
|
|
|
1358
1367
|
# Related: Array#compact!; see also [Methods for
|
|
1359
1368
|
# Deleting](rdoc-ref:Array@Methods+for+Deleting).
|
|
1360
1369
|
#
|
|
1361
|
-
def compact: () ->
|
|
1370
|
+
def compact: () -> Array[E] # it'd be nice if there was a way to do `Array[E - nil]`
|
|
1362
1371
|
|
|
1363
1372
|
# <!--
|
|
1364
1373
|
# rdoc-file=array.c
|
|
@@ -1389,7 +1398,7 @@ class Array[unchecked out E] < Object
|
|
|
1389
1398
|
#
|
|
1390
1399
|
# Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
|
|
1391
1400
|
#
|
|
1392
|
-
def concat: (
|
|
1401
|
+
def concat: (*array[E] other_arrays) -> self
|
|
1393
1402
|
|
|
1394
1403
|
# <!--
|
|
1395
1404
|
# rdoc-file=array.c
|
|
@@ -1418,9 +1427,8 @@ class Array[unchecked out E] < Object
|
|
|
1418
1427
|
#
|
|
1419
1428
|
# Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
|
|
1420
1429
|
#
|
|
1421
|
-
def count: () ->
|
|
1422
|
-
| (
|
|
1423
|
-
| () { (E) -> boolish } -> ::Integer
|
|
1430
|
+
def count: () ?{ (E element) -> boolish } -> Integer
|
|
1431
|
+
| (untyped object) -> Integer # where E: RBS::Ops::_Equal
|
|
1424
1432
|
|
|
1425
1433
|
# <!--
|
|
1426
1434
|
# rdoc-file=array.c
|
|
@@ -1454,8 +1462,8 @@ class Array[unchecked out E] < Object
|
|
|
1454
1462
|
#
|
|
1455
1463
|
# Related: see [Methods for Iterating](rdoc-ref:Array@Methods+for+Iterating).
|
|
1456
1464
|
#
|
|
1457
|
-
def cycle: (?int? n) { (E) -> void } -> nil
|
|
1458
|
-
| (?int? n) ->
|
|
1465
|
+
def cycle: (?int? n) { (E element) -> void } -> nil
|
|
1466
|
+
| (?int? n) -> Enumerator[E, nil]
|
|
1459
1467
|
|
|
1460
1468
|
# <!--
|
|
1461
1469
|
# rdoc-file=array.c
|
|
@@ -1499,8 +1507,8 @@ class Array[unchecked out E] < Object
|
|
|
1499
1507
|
#
|
|
1500
1508
|
# Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
|
|
1501
1509
|
#
|
|
1502
|
-
def delete: (
|
|
1503
|
-
| [S, T] (S
|
|
1510
|
+
def delete: (untyped object) -> E? # where E: _Comparable
|
|
1511
|
+
| [S, T] (S object) { (S object) -> T } -> (E | T)
|
|
1504
1512
|
|
|
1505
1513
|
# <!--
|
|
1506
1514
|
# rdoc-file=array.c
|
|
@@ -1548,7 +1556,24 @@ class Array[unchecked out E] < Object
|
|
|
1548
1556
|
# Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
|
|
1549
1557
|
#
|
|
1550
1558
|
def delete_if: () { (E item) -> boolish } -> self
|
|
1551
|
-
| () ->
|
|
1559
|
+
| () -> Enumerator[E, self]
|
|
1560
|
+
|
|
1561
|
+
# <!-- rdoc-file=array.c -->
|
|
1562
|
+
# Returns the first element for which the block returns a truthy value.
|
|
1563
|
+
#
|
|
1564
|
+
# With a block given, calls the block with successive elements of the array;
|
|
1565
|
+
# returns the first element for which the block returns a truthy value:
|
|
1566
|
+
#
|
|
1567
|
+
# [1, 3, 5].find {|element| element > 2} # => 3
|
|
1568
|
+
#
|
|
1569
|
+
# If no such element is found, calls `if_none_proc` and returns its return
|
|
1570
|
+
# value.
|
|
1571
|
+
#
|
|
1572
|
+
# [1, 3, 5].find(proc {-1}) {|element| element > 12} # => -1
|
|
1573
|
+
#
|
|
1574
|
+
# With no block given, returns an Enumerator.
|
|
1575
|
+
#
|
|
1576
|
+
alias detect find
|
|
1552
1577
|
|
|
1553
1578
|
# <!--
|
|
1554
1579
|
# rdoc-file=array.c
|
|
@@ -1568,7 +1593,7 @@ class Array[unchecked out E] < Object
|
|
|
1568
1593
|
# Related: Array#-; see also [Methods for
|
|
1569
1594
|
# Combining](rdoc-ref:Array@Methods+for+Combining).
|
|
1570
1595
|
#
|
|
1571
|
-
def difference: (
|
|
1596
|
+
def difference: (*array[untyped] other_arrays) -> Array[E]
|
|
1572
1597
|
|
|
1573
1598
|
# <!--
|
|
1574
1599
|
# rdoc-file=array.c
|
|
@@ -1588,8 +1613,8 @@ class Array[unchecked out E] < Object
|
|
|
1588
1613
|
#
|
|
1589
1614
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
1590
1615
|
#
|
|
1591
|
-
def dig: (int
|
|
1592
|
-
| (int
|
|
1616
|
+
def dig: (int index) -> E?
|
|
1617
|
+
| (int index, untyped, *untyped) -> untyped
|
|
1593
1618
|
|
|
1594
1619
|
# <!--
|
|
1595
1620
|
# rdoc-file=array.c
|
|
@@ -1608,7 +1633,7 @@ class Array[unchecked out E] < Object
|
|
|
1608
1633
|
#
|
|
1609
1634
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
1610
1635
|
#
|
|
1611
|
-
def drop: (int
|
|
1636
|
+
def drop: (int count) -> Array[E]
|
|
1612
1637
|
|
|
1613
1638
|
# <!--
|
|
1614
1639
|
# rdoc-file=array.c
|
|
@@ -1627,8 +1652,8 @@ class Array[unchecked out E] < Object
|
|
|
1627
1652
|
#
|
|
1628
1653
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
1629
1654
|
#
|
|
1630
|
-
def drop_while: () { (E
|
|
1631
|
-
| () ->
|
|
1655
|
+
def drop_while: () { (E element) -> boolish } -> Array[E]
|
|
1656
|
+
| () -> Enumerator[E, Array[E]]
|
|
1632
1657
|
|
|
1633
1658
|
# <!--
|
|
1634
1659
|
# rdoc-file=array.c
|
|
@@ -1661,8 +1686,8 @@ class Array[unchecked out E] < Object
|
|
|
1661
1686
|
#
|
|
1662
1687
|
# Related: see [Methods for Iterating](rdoc-ref:Array@Methods+for+Iterating).
|
|
1663
1688
|
#
|
|
1664
|
-
def each: ()
|
|
1665
|
-
| ()
|
|
1689
|
+
def each: () { (E element) -> void } -> self
|
|
1690
|
+
| () -> Enumerator[E, self]
|
|
1666
1691
|
|
|
1667
1692
|
# <!--
|
|
1668
1693
|
# rdoc-file=array.c
|
|
@@ -1696,8 +1721,8 @@ class Array[unchecked out E] < Object
|
|
|
1696
1721
|
#
|
|
1697
1722
|
# Related: see [Methods for Iterating](rdoc-ref:Array@Methods+for+Iterating).
|
|
1698
1723
|
#
|
|
1699
|
-
def each_index: () { (
|
|
1700
|
-
| () ->
|
|
1724
|
+
def each_index: () { (Integer index) -> void } -> self
|
|
1725
|
+
| () -> Enumerator[Integer, self]
|
|
1701
1726
|
|
|
1702
1727
|
# <!--
|
|
1703
1728
|
# rdoc-file=array.c
|
|
@@ -1771,7 +1796,7 @@ class Array[unchecked out E] < Object
|
|
|
1771
1796
|
#
|
|
1772
1797
|
def fetch: (int index) -> E
|
|
1773
1798
|
| [T] (int index, T default) -> (E | T)
|
|
1774
|
-
| [T] (
|
|
1799
|
+
| [I < _ToInt, T] (I index) { (I index) -> T } -> (E | T)
|
|
1775
1800
|
|
|
1776
1801
|
# <!--
|
|
1777
1802
|
# rdoc-file=array.rb
|
|
@@ -1808,7 +1833,8 @@ class Array[unchecked out E] < Object
|
|
|
1808
1833
|
#
|
|
1809
1834
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
1810
1835
|
#
|
|
1811
|
-
def fetch_values: (*int indexes) ->
|
|
1836
|
+
def fetch_values: (*int indexes) -> Array[E]
|
|
1837
|
+
| [I < _ToInt, T] (*I indexes) { (I index) -> T } -> Array[E | T]
|
|
1812
1838
|
|
|
1813
1839
|
# <!--
|
|
1814
1840
|
# rdoc-file=array.c
|
|
@@ -1988,11 +2014,10 @@ class Array[unchecked out E] < Object
|
|
|
1988
2014
|
#
|
|
1989
2015
|
# Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
|
|
1990
2016
|
#
|
|
1991
|
-
def fill: (E
|
|
1992
|
-
| (E
|
|
1993
|
-
| (
|
|
1994
|
-
| (
|
|
1995
|
-
| (::Range[::Integer] range) { (::Integer index) -> E } -> self
|
|
2017
|
+
def fill: (E object, ?int? start, ?int? length) -> self
|
|
2018
|
+
| (E object, range[int?] range) -> self
|
|
2019
|
+
| (?int? start, ?int? length) { (Integer index) -> E } -> self
|
|
2020
|
+
| (range[int?] range) { (Integer index) -> E } -> self
|
|
1996
2021
|
|
|
1997
2022
|
# <!-- rdoc-file=array.c -->
|
|
1998
2023
|
# With a block given, calls the block with each element of `self`; returns a new
|
|
@@ -2007,8 +2032,7 @@ class Array[unchecked out E] < Object
|
|
|
2007
2032
|
#
|
|
2008
2033
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
2009
2034
|
#
|
|
2010
|
-
|
|
2011
|
-
| () -> ::Enumerator[E, ::Array[E]]
|
|
2035
|
+
alias filter select
|
|
2012
2036
|
|
|
2013
2037
|
# <!-- rdoc-file=array.c -->
|
|
2014
2038
|
# With a block given, calls the block with each element of `self`; removes from
|
|
@@ -2025,8 +2049,7 @@ class Array[unchecked out E] < Object
|
|
|
2025
2049
|
#
|
|
2026
2050
|
# Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
|
|
2027
2051
|
#
|
|
2028
|
-
|
|
2029
|
-
| () -> ::Enumerator[E, self?]
|
|
2052
|
+
alias filter! select!
|
|
2030
2053
|
|
|
2031
2054
|
# <!--
|
|
2032
2055
|
# rdoc-file=array.c
|
|
@@ -2048,9 +2071,9 @@ class Array[unchecked out E] < Object
|
|
|
2048
2071
|
# With no block given, returns an Enumerator.
|
|
2049
2072
|
#
|
|
2050
2073
|
def find: () { (E) -> boolish } -> E?
|
|
2051
|
-
| () ->
|
|
2052
|
-
| [T] (Enumerable::_NotFound[T] ifnone) { (E) -> boolish } -> (E | T)
|
|
2053
|
-
| [T] (Enumerable::_NotFound[T] ifnone) ->
|
|
2074
|
+
| () -> Enumerator[E, E?]
|
|
2075
|
+
| [T] (Enumerable::_NotFound[T]? ifnone) { (E) -> boolish } -> (E | T)
|
|
2076
|
+
| [T] (Enumerable::_NotFound[T]? ifnone) -> Enumerator[E, E | T]
|
|
2054
2077
|
|
|
2055
2078
|
# <!--
|
|
2056
2079
|
# rdoc-file=array.c
|
|
@@ -2083,9 +2106,9 @@ class Array[unchecked out E] < Object
|
|
|
2083
2106
|
#
|
|
2084
2107
|
# Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
|
|
2085
2108
|
#
|
|
2086
|
-
def find_index: (untyped
|
|
2087
|
-
| () { (E
|
|
2088
|
-
| () ->
|
|
2109
|
+
def find_index: (untyped object) -> Integer? # where E: RBS::Ops::_Equal
|
|
2110
|
+
| () { (E element) -> boolish } -> Integer?
|
|
2111
|
+
| () -> Enumerator[E, Integer?]
|
|
2089
2112
|
|
|
2090
2113
|
# <!--
|
|
2091
2114
|
# rdoc-file=array.rb
|
|
@@ -2114,7 +2137,7 @@ class Array[unchecked out E] < Object
|
|
|
2114
2137
|
# Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
|
|
2115
2138
|
#
|
|
2116
2139
|
def first: %a{implicitly-returns-nil} () -> E
|
|
2117
|
-
| (int
|
|
2140
|
+
| (int count) -> Array[E]
|
|
2118
2141
|
|
|
2119
2142
|
# <!--
|
|
2120
2143
|
# rdoc-file=array.c
|
|
@@ -2149,7 +2172,7 @@ class Array[unchecked out E] < Object
|
|
|
2149
2172
|
# Related: Array#flatten!; see also [Methods for
|
|
2150
2173
|
# Converting](rdoc-ref:Array@Methods+for+Converting).
|
|
2151
2174
|
#
|
|
2152
|
-
def flatten: (?int level) ->
|
|
2175
|
+
def flatten: (?int? level) -> Array[untyped]
|
|
2153
2176
|
|
|
2154
2177
|
# <!--
|
|
2155
2178
|
# rdoc-file=array.c
|
|
@@ -2185,7 +2208,25 @@ class Array[unchecked out E] < Object
|
|
|
2185
2208
|
# Related: Array#flatten; see also [Methods for
|
|
2186
2209
|
# Assigning](rdoc-ref:Array@Methods+for+Assigning).
|
|
2187
2210
|
#
|
|
2188
|
-
def flatten!: (?int level) -> self?
|
|
2211
|
+
def flatten!: (?int? level) -> self?
|
|
2212
|
+
|
|
2213
|
+
# <!--
|
|
2214
|
+
# rdoc-file=array.c
|
|
2215
|
+
# - freeze -> self
|
|
2216
|
+
# -->
|
|
2217
|
+
# Freezes `self` (if not already frozen); returns `self`:
|
|
2218
|
+
#
|
|
2219
|
+
# a = []
|
|
2220
|
+
# a.frozen? # => false
|
|
2221
|
+
# a.freeze
|
|
2222
|
+
# a.frozen? # => true
|
|
2223
|
+
#
|
|
2224
|
+
# No further changes may be made to `self`; raises FrozenError if a change is
|
|
2225
|
+
# attempted.
|
|
2226
|
+
#
|
|
2227
|
+
# Related: Kernel#frozen?.
|
|
2228
|
+
#
|
|
2229
|
+
def freeze: () -> self
|
|
2189
2230
|
|
|
2190
2231
|
# <!--
|
|
2191
2232
|
# rdoc-file=array.c
|
|
@@ -2200,7 +2241,7 @@ class Array[unchecked out E] < Object
|
|
|
2200
2241
|
# ['a', 'b'].hash == ['a', 'c'].hash # => false
|
|
2201
2242
|
# ['a', 'b'].hash == ['a'].hash # => false
|
|
2202
2243
|
#
|
|
2203
|
-
def hash: () ->
|
|
2244
|
+
def hash: () -> Integer # where E: _Hash
|
|
2204
2245
|
|
|
2205
2246
|
# <!--
|
|
2206
2247
|
# rdoc-file=array.c
|
|
@@ -2215,7 +2256,7 @@ class Array[unchecked out E] < Object
|
|
|
2215
2256
|
#
|
|
2216
2257
|
# Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
|
|
2217
2258
|
#
|
|
2218
|
-
def include?: (
|
|
2259
|
+
def include?: (untyped object) -> bool # where E: RBS::Ops::_Equals
|
|
2219
2260
|
|
|
2220
2261
|
# <!-- rdoc-file=array.c -->
|
|
2221
2262
|
# Returns the zero-based integer index of a specified element, or `nil`.
|
|
@@ -2278,7 +2319,7 @@ class Array[unchecked out E] < Object
|
|
|
2278
2319
|
#
|
|
2279
2320
|
# Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
|
|
2280
2321
|
#
|
|
2281
|
-
def insert: (int index, *E
|
|
2322
|
+
def insert: (int index, *E objects) -> self
|
|
2282
2323
|
|
|
2283
2324
|
# <!--
|
|
2284
2325
|
# rdoc-file=array.c
|
|
@@ -2293,7 +2334,7 @@ class Array[unchecked out E] < Object
|
|
|
2293
2334
|
#
|
|
2294
2335
|
# Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting).
|
|
2295
2336
|
#
|
|
2296
|
-
def inspect: () -> String
|
|
2337
|
+
def inspect: () -> String # where E: _Inspect
|
|
2297
2338
|
|
|
2298
2339
|
# <!--
|
|
2299
2340
|
# rdoc-file=array.c
|
|
@@ -2309,7 +2350,7 @@ class Array[unchecked out E] < Object
|
|
|
2309
2350
|
#
|
|
2310
2351
|
# Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
|
|
2311
2352
|
#
|
|
2312
|
-
def intersect?: (
|
|
2353
|
+
def intersect?: (array[untyped] other_array) -> bool # where E: _Eql?
|
|
2313
2354
|
|
|
2314
2355
|
# <!--
|
|
2315
2356
|
# rdoc-file=array.c
|
|
@@ -2331,7 +2372,7 @@ class Array[unchecked out E] < Object
|
|
|
2331
2372
|
#
|
|
2332
2373
|
# Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
|
|
2333
2374
|
#
|
|
2334
|
-
def intersection: (
|
|
2375
|
+
def intersection: (*array[untyped] other_arrays) -> Array[E] # where E: _Eql?
|
|
2335
2376
|
|
|
2336
2377
|
# <!--
|
|
2337
2378
|
# rdoc-file=array.c
|
|
@@ -2363,7 +2404,7 @@ class Array[unchecked out E] < Object
|
|
|
2363
2404
|
#
|
|
2364
2405
|
# Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting).
|
|
2365
2406
|
#
|
|
2366
|
-
def join: (?string separator) -> String
|
|
2407
|
+
def join: (?string? separator) -> String # where E: _ToS
|
|
2367
2408
|
|
|
2368
2409
|
# <!--
|
|
2369
2410
|
# rdoc-file=array.c
|
|
@@ -2380,8 +2421,8 @@ class Array[unchecked out E] < Object
|
|
|
2380
2421
|
#
|
|
2381
2422
|
# Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
|
|
2382
2423
|
#
|
|
2383
|
-
def keep_if: () { (E
|
|
2384
|
-
| () ->
|
|
2424
|
+
def keep_if: () { (E element) -> boolish } -> self
|
|
2425
|
+
| () -> Enumerator[E, self]
|
|
2385
2426
|
|
|
2386
2427
|
# <!--
|
|
2387
2428
|
# rdoc-file=array.rb
|
|
@@ -2409,7 +2450,7 @@ class Array[unchecked out E] < Object
|
|
|
2409
2450
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
2410
2451
|
#
|
|
2411
2452
|
def last: %a{implicitly-returns-nil} () -> E
|
|
2412
|
-
| (int
|
|
2453
|
+
| (int count) -> Array[E]
|
|
2413
2454
|
|
|
2414
2455
|
# <!--
|
|
2415
2456
|
# rdoc-file=array.c
|
|
@@ -2423,7 +2464,7 @@ class Array[unchecked out E] < Object
|
|
|
2423
2464
|
#
|
|
2424
2465
|
# Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
|
|
2425
2466
|
#
|
|
2426
|
-
def length: () ->
|
|
2467
|
+
def length: () -> Integer
|
|
2427
2468
|
|
|
2428
2469
|
# <!-- rdoc-file=array.c -->
|
|
2429
2470
|
# With a block given, calls the block with each element of `self`; returns a new
|
|
@@ -2502,10 +2543,12 @@ class Array[unchecked out E] < Object
|
|
|
2502
2543
|
#
|
|
2503
2544
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
2504
2545
|
#
|
|
2505
|
-
def max: %a{implicitly-returns-nil} () -> E
|
|
2506
|
-
| %a{implicitly-returns-nil} () { (E a, E b) -> ::
|
|
2507
|
-
| (
|
|
2508
|
-
| (int
|
|
2546
|
+
def max: %a{implicitly-returns-nil} () -> E # where E: Comparable::_WithSpaceshipOperator
|
|
2547
|
+
| %a{implicitly-returns-nil} () { (E a, E b) -> Comparable::_CompareToZero } -> E
|
|
2548
|
+
| %a{implicitly-returns-nil} %a{warning: returning `nil` will always raise at runtime} () { (E a, E b) -> Comparable::_CompareToZero? } -> E
|
|
2549
|
+
| (int count) -> Array[E] # where E: Comparable::_WithSpaceshipOperator
|
|
2550
|
+
| (int count) { (E a, E b) -> Comparable::_CompareToZero } -> Array[E]
|
|
2551
|
+
| %a{warning: returning `nil` will always raise at runtime} (int count) { (E a, E b) -> Comparable::_CompareToZero? } -> Array[E]
|
|
2509
2552
|
|
|
2510
2553
|
# <!--
|
|
2511
2554
|
# rdoc-file=array.c
|
|
@@ -2555,7 +2598,12 @@ class Array[unchecked out E] < Object
|
|
|
2555
2598
|
#
|
|
2556
2599
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
2557
2600
|
#
|
|
2558
|
-
|
|
2601
|
+
def min: %a{implicitly-returns-nil} () -> E # where E: Comparable::_WithSpaceshipOperator
|
|
2602
|
+
| %a{implicitly-returns-nil} () { (E a, E b) -> Comparable::_CompareToZero } -> E
|
|
2603
|
+
| %a{implicitly-returns-nil} %a{warning: returning `nil` will always raise at runtime} () { (E a, E b) -> Comparable::_CompareToZero? } -> E
|
|
2604
|
+
| (int count) -> Array[E] # where E: Comparable::_WithSpaceshipOperator
|
|
2605
|
+
| (int count) { (E a, E b) -> Comparable::_CompareToZero } -> Array[E]
|
|
2606
|
+
| %a{warning: returning `nil` will always raise at runtime} (int count) { (E a, E b) -> Comparable::_CompareToZero? } -> Array[E]
|
|
2559
2607
|
|
|
2560
2608
|
# <!--
|
|
2561
2609
|
# rdoc-file=array.c
|
|
@@ -2579,8 +2627,9 @@ class Array[unchecked out E] < Object
|
|
|
2579
2627
|
#
|
|
2580
2628
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
2581
2629
|
#
|
|
2582
|
-
def minmax: () -> [ E?, E? ]
|
|
2583
|
-
| () { (E a, E b) -> ::
|
|
2630
|
+
def minmax: () -> [ E?, E? ] # where E: Comparable::_WithSpaceshipOperator
|
|
2631
|
+
| () { (E a, E b) -> Comparable::_CompareToZero } -> [ E?, E? ]
|
|
2632
|
+
| %a{warning: returning `nil` will always raise at runtime} () { (E a, E b) -> Comparable::_CompareToZero? } -> [ E?, E? ]
|
|
2584
2633
|
|
|
2585
2634
|
# <!--
|
|
2586
2635
|
# rdoc-file=array.c
|
|
@@ -2615,7 +2664,9 @@ class Array[unchecked out E] < Object
|
|
|
2615
2664
|
#
|
|
2616
2665
|
# Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
|
|
2617
2666
|
#
|
|
2618
|
-
|
|
2667
|
+
def none?: () -> bool
|
|
2668
|
+
| (RBS::Ops::_CaseEqual[E, boolish] pattern) -> bool
|
|
2669
|
+
| () { (E element) -> boolish } -> bool
|
|
2619
2670
|
|
|
2620
2671
|
# <!--
|
|
2621
2672
|
# rdoc-file=array.c
|
|
@@ -2652,7 +2703,9 @@ class Array[unchecked out E] < Object
|
|
|
2652
2703
|
#
|
|
2653
2704
|
# Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
|
|
2654
2705
|
#
|
|
2655
|
-
|
|
2706
|
+
def one?: () -> bool
|
|
2707
|
+
| (RBS::Ops::_CaseEqual[E, boolish] pattern) -> bool
|
|
2708
|
+
| () { (E element) -> boolish } -> bool
|
|
2656
2709
|
|
|
2657
2710
|
# <!--
|
|
2658
2711
|
# rdoc-file=pack.rb
|
|
@@ -2704,8 +2757,8 @@ class Array[unchecked out E] < Object
|
|
|
2704
2757
|
#
|
|
2705
2758
|
# Related: [Methods for Iterating](rdoc-ref:Array@Methods+for+Iterating).
|
|
2706
2759
|
#
|
|
2707
|
-
def permutation: (?int
|
|
2708
|
-
| (?int
|
|
2760
|
+
def permutation: (?int? count) { (Array[E] permutation) -> void } -> self
|
|
2761
|
+
| (?int? count) -> Enumerator[Array[E], self]
|
|
2709
2762
|
|
|
2710
2763
|
# <!--
|
|
2711
2764
|
# rdoc-file=array.c
|
|
@@ -2737,7 +2790,7 @@ class Array[unchecked out E] < Object
|
|
|
2737
2790
|
# Deleting](rdoc-ref:Array@Methods+for+Deleting).
|
|
2738
2791
|
#
|
|
2739
2792
|
def pop: () -> E?
|
|
2740
|
-
| (int
|
|
2793
|
+
| (int count) -> Array[E]
|
|
2741
2794
|
|
|
2742
2795
|
# <!-- rdoc-file=array.c -->
|
|
2743
2796
|
# Prepends the given `objects` to `self`:
|
|
@@ -2803,10 +2856,14 @@ class Array[unchecked out E] < Object
|
|
|
2803
2856
|
#
|
|
2804
2857
|
# Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
|
|
2805
2858
|
#
|
|
2806
|
-
def product: () ->
|
|
2807
|
-
|
|
|
2808
|
-
| [X
|
|
2809
|
-
| [
|
|
2859
|
+
def product: () -> Array[[ E ]]
|
|
2860
|
+
| () { ([E] combination) -> void } -> self
|
|
2861
|
+
| [X] (array[X] other_ary) -> Array[[ E, X ]]
|
|
2862
|
+
| [X] (array[X] other_ary) { ([E, X] combination) -> void } -> self
|
|
2863
|
+
| [X, Y] (array[X] other_ary1, array[Y] other_ary2) -> Array[[ E, X, Y ]]
|
|
2864
|
+
| [X, Y] (array[X] other_ary1, array[Y] other_ary2) { ([E, X, Y] combination) -> void } -> self
|
|
2865
|
+
| [U] (*array[U] other_arys) -> Array[Array[E | U]]
|
|
2866
|
+
| [U] (*array[U] other_arys) { (Array[E | U] combination) -> void } -> self
|
|
2810
2867
|
|
|
2811
2868
|
# <!--
|
|
2812
2869
|
# rdoc-file=array.c
|
|
@@ -2825,7 +2882,7 @@ class Array[unchecked out E] < Object
|
|
|
2825
2882
|
#
|
|
2826
2883
|
# Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
|
|
2827
2884
|
#
|
|
2828
|
-
def push: (*E
|
|
2885
|
+
def push: (*E objects) -> self
|
|
2829
2886
|
|
|
2830
2887
|
# <!--
|
|
2831
2888
|
# rdoc-file=array.c
|
|
@@ -2843,7 +2900,7 @@ class Array[unchecked out E] < Object
|
|
|
2843
2900
|
# Related: Array#assoc; see also [Methods for
|
|
2844
2901
|
# Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
2845
2902
|
#
|
|
2846
|
-
|
|
2903
|
+
def rassoc: (untyped object) -> Array[untyped]? # where E: _ToAry, object: _Equal
|
|
2847
2904
|
|
|
2848
2905
|
# <!--
|
|
2849
2906
|
# rdoc-file=array.c
|
|
@@ -2883,7 +2940,7 @@ class Array[unchecked out E] < Object
|
|
|
2883
2940
|
# Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
|
|
2884
2941
|
#
|
|
2885
2942
|
def reject!: () { (E item) -> boolish } -> self?
|
|
2886
|
-
| () ->
|
|
2943
|
+
| () -> Enumerator[E, self?]
|
|
2887
2944
|
|
|
2888
2945
|
# <!--
|
|
2889
2946
|
# rdoc-file=array.c
|
|
@@ -2922,8 +2979,8 @@ class Array[unchecked out E] < Object
|
|
|
2922
2979
|
#
|
|
2923
2980
|
# Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
|
|
2924
2981
|
#
|
|
2925
|
-
def repeated_combination: (int
|
|
2926
|
-
| (int
|
|
2982
|
+
def repeated_combination: (int size) { (Array[E] combination) -> void } -> self
|
|
2983
|
+
| (int size) -> Enumerator[Array[E], self]
|
|
2927
2984
|
|
|
2928
2985
|
# <!--
|
|
2929
2986
|
# rdoc-file=array.c
|
|
@@ -2962,8 +3019,8 @@ class Array[unchecked out E] < Object
|
|
|
2962
3019
|
#
|
|
2963
3020
|
# Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
|
|
2964
3021
|
#
|
|
2965
|
-
def repeated_permutation: (int
|
|
2966
|
-
| (int
|
|
3022
|
+
def repeated_permutation: (int size) { (Array[E] permutation) -> void } -> self
|
|
3023
|
+
| (int size) -> Enumerator[Array[E], self]
|
|
2967
3024
|
|
|
2968
3025
|
# <!-- rdoc-file=array.c -->
|
|
2969
3026
|
# Replaces the elements of `self` with the elements of `other_array`, which must
|
|
@@ -2976,7 +3033,7 @@ class Array[unchecked out E] < Object
|
|
|
2976
3033
|
#
|
|
2977
3034
|
# Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
|
|
2978
3035
|
#
|
|
2979
|
-
def replace: (
|
|
3036
|
+
def replace: (array[E] other_array) -> self
|
|
2980
3037
|
|
|
2981
3038
|
# <!--
|
|
2982
3039
|
# rdoc-file=array.c
|
|
@@ -2988,7 +3045,7 @@ class Array[unchecked out E] < Object
|
|
|
2988
3045
|
#
|
|
2989
3046
|
# Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
|
|
2990
3047
|
#
|
|
2991
|
-
def reverse: () ->
|
|
3048
|
+
def reverse: () -> Array[E]
|
|
2992
3049
|
|
|
2993
3050
|
# <!--
|
|
2994
3051
|
# rdoc-file=array.c
|
|
@@ -3002,7 +3059,7 @@ class Array[unchecked out E] < Object
|
|
|
3002
3059
|
#
|
|
3003
3060
|
# Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
|
|
3004
3061
|
#
|
|
3005
|
-
def reverse!: () ->
|
|
3062
|
+
def reverse!: () -> self
|
|
3006
3063
|
|
|
3007
3064
|
# <!--
|
|
3008
3065
|
# rdoc-file=array.c
|
|
@@ -3026,8 +3083,8 @@ class Array[unchecked out E] < Object
|
|
|
3026
3083
|
#
|
|
3027
3084
|
# Related: see [Methods for Iterating](rdoc-ref:Array@Methods+for+Iterating).
|
|
3028
3085
|
#
|
|
3029
|
-
def reverse_each: () { (E
|
|
3030
|
-
| () ->
|
|
3086
|
+
def reverse_each: () { (E element) -> void } -> self
|
|
3087
|
+
| () -> Enumerator[E, self]
|
|
3031
3088
|
|
|
3032
3089
|
# <!--
|
|
3033
3090
|
# rdoc-file=array.c
|
|
@@ -3050,9 +3107,9 @@ class Array[unchecked out E] < Object
|
|
|
3050
3107
|
# With no block given, returns an Enumerator.
|
|
3051
3108
|
#
|
|
3052
3109
|
def rfind: () { (E) -> boolish } -> E?
|
|
3053
|
-
| () ->
|
|
3054
|
-
| [T] (Enumerable::_NotFound[T] ifnone) { (E) -> boolish } -> (E | T)
|
|
3055
|
-
| [T] (Enumerable::_NotFound[T] ifnone) ->
|
|
3110
|
+
| () -> Enumerator[E, E?]
|
|
3111
|
+
| [T] (Enumerable::_NotFound[T]? ifnone) { (E) -> boolish } -> (E | T)
|
|
3112
|
+
| [T] (Enumerable::_NotFound[T]? ifnone) -> Enumerator[E, E | T]
|
|
3056
3113
|
|
|
3057
3114
|
# <!--
|
|
3058
3115
|
# rdoc-file=array.c
|
|
@@ -3083,9 +3140,9 @@ class Array[unchecked out E] < Object
|
|
|
3083
3140
|
#
|
|
3084
3141
|
# Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
|
|
3085
3142
|
#
|
|
3086
|
-
def rindex: (untyped
|
|
3087
|
-
| () { (E
|
|
3088
|
-
| () ->
|
|
3143
|
+
def rindex: (untyped object) -> Integer? # where E: _Equal
|
|
3144
|
+
| () { (E element) -> boolish } -> Integer?
|
|
3145
|
+
| () -> Enumerator[E, Integer?]
|
|
3089
3146
|
|
|
3090
3147
|
# <!--
|
|
3091
3148
|
# rdoc-file=array.c
|
|
@@ -3120,7 +3177,7 @@ class Array[unchecked out E] < Object
|
|
|
3120
3177
|
#
|
|
3121
3178
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
3122
3179
|
#
|
|
3123
|
-
def rotate: (?int count) ->
|
|
3180
|
+
def rotate: (?int count) -> Array[E]
|
|
3124
3181
|
|
|
3125
3182
|
# <!--
|
|
3126
3183
|
# rdoc-file=array.c
|
|
@@ -3206,8 +3263,8 @@ class Array[unchecked out E] < Object
|
|
|
3206
3263
|
#
|
|
3207
3264
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
3208
3265
|
#
|
|
3209
|
-
def sample: %a{implicitly-returns-nil} (?random: _Rand
|
|
3210
|
-
| (int
|
|
3266
|
+
def sample: %a{implicitly-returns-nil} (?random: _Rand) -> E
|
|
3267
|
+
| (int count, ?random: _Rand) -> Array[E]
|
|
3211
3268
|
|
|
3212
3269
|
# <!--
|
|
3213
3270
|
# rdoc-file=array.c
|
|
@@ -3228,8 +3285,8 @@ class Array[unchecked out E] < Object
|
|
|
3228
3285
|
#
|
|
3229
3286
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
3230
3287
|
#
|
|
3231
|
-
def select: () { (E
|
|
3232
|
-
| () ->
|
|
3288
|
+
def select: () { (E element) -> boolish } -> Array[E]
|
|
3289
|
+
| () -> Enumerator[E, Array[E]]
|
|
3233
3290
|
|
|
3234
3291
|
# <!--
|
|
3235
3292
|
# rdoc-file=array.c
|
|
@@ -3252,8 +3309,8 @@ class Array[unchecked out E] < Object
|
|
|
3252
3309
|
#
|
|
3253
3310
|
# Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
|
|
3254
3311
|
#
|
|
3255
|
-
def select!: () { (E
|
|
3256
|
-
| () ->
|
|
3312
|
+
def select!: () { (E element) -> boolish } -> self?
|
|
3313
|
+
| () -> Enumerator[E, self?]
|
|
3257
3314
|
|
|
3258
3315
|
# <!--
|
|
3259
3316
|
# rdoc-file=array.c
|
|
@@ -3292,7 +3349,7 @@ class Array[unchecked out E] < Object
|
|
|
3292
3349
|
# Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
|
|
3293
3350
|
#
|
|
3294
3351
|
def shift: %a{implicitly-returns-nil} () -> E
|
|
3295
|
-
| (int
|
|
3352
|
+
| (int count) -> Array[E]
|
|
3296
3353
|
|
|
3297
3354
|
# <!--
|
|
3298
3355
|
# rdoc-file=array.rb
|
|
@@ -3316,7 +3373,7 @@ class Array[unchecked out E] < Object
|
|
|
3316
3373
|
#
|
|
3317
3374
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
3318
3375
|
#
|
|
3319
|
-
def shuffle: (?random: _Rand
|
|
3376
|
+
def shuffle: (?random: _Rand) -> Array[E]
|
|
3320
3377
|
|
|
3321
3378
|
# <!--
|
|
3322
3379
|
# rdoc-file=array.rb
|
|
@@ -3340,7 +3397,7 @@ class Array[unchecked out E] < Object
|
|
|
3340
3397
|
#
|
|
3341
3398
|
# Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
|
|
3342
3399
|
#
|
|
3343
|
-
def shuffle!: (?random: _Rand
|
|
3400
|
+
def shuffle!: (?random: _Rand) -> self
|
|
3344
3401
|
|
|
3345
3402
|
# <!-- rdoc-file=array.c -->
|
|
3346
3403
|
# Returns the count of elements in `self`:
|
|
@@ -3464,9 +3521,7 @@ class Array[unchecked out E] < Object
|
|
|
3464
3521
|
#
|
|
3465
3522
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
3466
3523
|
#
|
|
3467
|
-
|
|
3468
|
-
| (int start, int length) -> ::Array[E]?
|
|
3469
|
-
| (::Range[::Integer] range) -> ::Array[E]?
|
|
3524
|
+
alias slice []
|
|
3470
3525
|
|
|
3471
3526
|
# <!--
|
|
3472
3527
|
# rdoc-file=array.c
|
|
@@ -3559,8 +3614,8 @@ class Array[unchecked out E] < Object
|
|
|
3559
3614
|
# Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
|
|
3560
3615
|
#
|
|
3561
3616
|
def slice!: %a{implicitly-returns-nil} (int index) -> E
|
|
3562
|
-
| (int start, int length) ->
|
|
3563
|
-
| (
|
|
3617
|
+
| (int start, int length) -> Array[E]?
|
|
3618
|
+
| (range[int?] range) -> Array[E]?
|
|
3564
3619
|
|
|
3565
3620
|
# <!--
|
|
3566
3621
|
# rdoc-file=array.c
|
|
@@ -3595,8 +3650,9 @@ class Array[unchecked out E] < Object
|
|
|
3595
3650
|
#
|
|
3596
3651
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
3597
3652
|
#
|
|
3598
|
-
def sort: () ->
|
|
3599
|
-
| () { (E a, E b) -> ::
|
|
3653
|
+
def sort: () -> Array[E] # where E: Comparable::_WithSpaceshipOperator
|
|
3654
|
+
| () { (E a, E b) -> Comparable::_CompareToZero } -> Array[E]
|
|
3655
|
+
| %a{warning: returning `nil` will always raise at runtime} () { (E a, E b) -> Comparable::_CompareToZero? } -> Array[E]
|
|
3600
3656
|
|
|
3601
3657
|
# <!--
|
|
3602
3658
|
# rdoc-file=array.c
|
|
@@ -3607,8 +3663,9 @@ class Array[unchecked out E] < Object
|
|
|
3607
3663
|
#
|
|
3608
3664
|
# Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
|
|
3609
3665
|
#
|
|
3610
|
-
def sort!: () -> self
|
|
3611
|
-
| () { (E a, E b) -> ::
|
|
3666
|
+
def sort!: () -> self # where E: Comparable::_WithSpaceshipOperator
|
|
3667
|
+
| () { (E a, E b) -> Comparable::_CompareToZero } -> self
|
|
3668
|
+
| %a{warning: returning `nil` will always raise at runtime} () { (E a, E b) -> Comparable::_CompareToZero? } -> self
|
|
3612
3669
|
|
|
3613
3670
|
# <!--
|
|
3614
3671
|
# rdoc-file=array.c
|
|
@@ -3631,8 +3688,9 @@ class Array[unchecked out E] < Object
|
|
|
3631
3688
|
#
|
|
3632
3689
|
# Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
|
|
3633
3690
|
#
|
|
3634
|
-
def sort_by!:
|
|
3635
|
-
| () -> ::
|
|
3691
|
+
def sort_by!: () { (E element) -> Comparable::_WithSpaceshipOperator } -> self
|
|
3692
|
+
| %a{warning: returning `nil` will always raise at runtime} () { (E element) -> Comparable::_WithSpaceshipOperator? } -> self
|
|
3693
|
+
| () -> Enumerator[E, self]
|
|
3636
3694
|
|
|
3637
3695
|
# <!--
|
|
3638
3696
|
# rdoc-file=array.c
|
|
@@ -3676,8 +3734,7 @@ class Array[unchecked out E] < Object
|
|
|
3676
3734
|
# * Array#sum method may not respect method redefinition of "+" methods such
|
|
3677
3735
|
# as Integer#+.
|
|
3678
3736
|
#
|
|
3679
|
-
def sum: (?untyped init) -> untyped
|
|
3680
|
-
| (?untyped init) { (E e) -> untyped } -> untyped
|
|
3737
|
+
def sum: (?untyped init) ?{ (E e) -> untyped } -> untyped # This would be usable if we had `where E < Complex`, etc
|
|
3681
3738
|
|
|
3682
3739
|
# <!--
|
|
3683
3740
|
# rdoc-file=array.c
|
|
@@ -3694,7 +3751,7 @@ class Array[unchecked out E] < Object
|
|
|
3694
3751
|
#
|
|
3695
3752
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
3696
3753
|
#
|
|
3697
|
-
def take: (int
|
|
3754
|
+
def take: (int count) -> Array[E]
|
|
3698
3755
|
|
|
3699
3756
|
# <!--
|
|
3700
3757
|
# rdoc-file=array.c
|
|
@@ -3716,8 +3773,8 @@ class Array[unchecked out E] < Object
|
|
|
3716
3773
|
#
|
|
3717
3774
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
3718
3775
|
#
|
|
3719
|
-
def take_while: () { (E
|
|
3720
|
-
| () ->
|
|
3776
|
+
def take_while: () { (E element) -> boolish } -> Array[E]
|
|
3777
|
+
| () -> Enumerator[E, Array[E]]
|
|
3721
3778
|
|
|
3722
3779
|
# <!--
|
|
3723
3780
|
# rdoc-file=array.c
|
|
@@ -3735,7 +3792,7 @@ class Array[unchecked out E] < Object
|
|
|
3735
3792
|
#
|
|
3736
3793
|
# Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting).
|
|
3737
3794
|
#
|
|
3738
|
-
def to_a: () ->
|
|
3795
|
+
def to_a: () -> Array[E]
|
|
3739
3796
|
|
|
3740
3797
|
# <!--
|
|
3741
3798
|
# rdoc-file=array.c
|
|
@@ -3770,7 +3827,7 @@ class Array[unchecked out E] < Object
|
|
|
3770
3827
|
# Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting).
|
|
3771
3828
|
#
|
|
3772
3829
|
def to_h: () -> Hash[untyped, untyped]
|
|
3773
|
-
| [
|
|
3830
|
+
| [K, V] () { (E element) -> Hash::_Pair[K, V] } -> Hash[K, V]
|
|
3774
3831
|
|
|
3775
3832
|
# <!-- rdoc-file=array.c -->
|
|
3776
3833
|
# Returns the new string formed by calling method <code>#inspect</code> on each
|
|
@@ -3797,7 +3854,7 @@ class Array[unchecked out E] < Object
|
|
|
3797
3854
|
#
|
|
3798
3855
|
# Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting).
|
|
3799
3856
|
#
|
|
3800
|
-
def transpose: () ->
|
|
3857
|
+
def transpose: () -> Array[Array[untyped]]
|
|
3801
3858
|
|
|
3802
3859
|
# <!--
|
|
3803
3860
|
# rdoc-file=array.c
|
|
@@ -3820,7 +3877,7 @@ class Array[unchecked out E] < Object
|
|
|
3820
3877
|
#
|
|
3821
3878
|
# Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
|
|
3822
3879
|
#
|
|
3823
|
-
def union: [T] (
|
|
3880
|
+
def union: [T] (*array[T] other_arrays) -> Array[T | E] # where E: _Eql?[T]
|
|
3824
3881
|
|
|
3825
3882
|
# <!--
|
|
3826
3883
|
# rdoc-file=array.c
|
|
@@ -3846,8 +3903,8 @@ class Array[unchecked out E] < Object
|
|
|
3846
3903
|
#
|
|
3847
3904
|
# Related: [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
3848
3905
|
#
|
|
3849
|
-
def uniq: () ->
|
|
3850
|
-
| () { (E
|
|
3906
|
+
def uniq: () -> Array[E] # where E: Hash::_Key
|
|
3907
|
+
| () { (E element) -> Hash::_Key } -> Array[E]
|
|
3851
3908
|
|
|
3852
3909
|
# <!--
|
|
3853
3910
|
# rdoc-file=array.c
|
|
@@ -3875,8 +3932,8 @@ class Array[unchecked out E] < Object
|
|
|
3875
3932
|
#
|
|
3876
3933
|
# Related: see [Methods for Deleting](rdoc-ref:Array@Methods+for+Deleting).
|
|
3877
3934
|
#
|
|
3878
|
-
def uniq!: () -> self?
|
|
3879
|
-
| () { (E) ->
|
|
3935
|
+
def uniq!: () -> self? # where E: Hash::_Key
|
|
3936
|
+
| () { (E element) -> Hash::_Key } -> self?
|
|
3880
3937
|
|
|
3881
3938
|
# <!--
|
|
3882
3939
|
# rdoc-file=array.c
|
|
@@ -3891,7 +3948,7 @@ class Array[unchecked out E] < Object
|
|
|
3891
3948
|
# Related: Array#shift; see also [Methods for
|
|
3892
3949
|
# Assigning](rdoc-ref:Array@Methods+for+Assigning).
|
|
3893
3950
|
#
|
|
3894
|
-
def unshift: (*E
|
|
3951
|
+
def unshift: (*E objects) -> self
|
|
3895
3952
|
|
|
3896
3953
|
# <!--
|
|
3897
3954
|
# rdoc-file=array.c
|
|
@@ -3999,7 +4056,7 @@ class Array[unchecked out E] < Object
|
|
|
3999
4056
|
#
|
|
4000
4057
|
# Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
|
|
4001
4058
|
#
|
|
4002
|
-
def values_at: (*int |
|
|
4059
|
+
def values_at: (*int | range[int?] selector) -> Array[E?]
|
|
4003
4060
|
|
|
4004
4061
|
# <!--
|
|
4005
4062
|
# rdoc-file=array.c
|
|
@@ -4093,10 +4150,14 @@ class Array[unchecked out E] < Object
|
|
|
4093
4150
|
#
|
|
4094
4151
|
# Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting).
|
|
4095
4152
|
#
|
|
4096
|
-
def zip:
|
|
4097
|
-
|
|
|
4098
|
-
| [
|
|
4099
|
-
|
|
|
4153
|
+
def zip: () -> Array[[ E ]]
|
|
4154
|
+
| [X] (_Each[X] iterable) -> Array[[ E, X? ]]
|
|
4155
|
+
| [X, Y] (_Each[X] iterable1, _Each[Y] iterable2) -> Array[[ E, X?, Y? ]]
|
|
4156
|
+
| [U] (*_Each[U] iterables) -> Array[Array[E | U?]]
|
|
4157
|
+
| () { ([ E ]) -> void } -> nil
|
|
4158
|
+
| [X] (_Each[X] iterable) { ([ E, X? ]) -> void } -> nil
|
|
4159
|
+
| [X, Y] (_Each[X] iterable1, _Each[Y] iterable2) { ([ E, X?, Y? ]) -> void } -> nil
|
|
4160
|
+
| [U] (*_Each[U] iterables) { (Array[E | U?]) -> void } -> nil
|
|
4100
4161
|
|
|
4101
4162
|
# <!--
|
|
4102
4163
|
# rdoc-file=array.c
|
|
@@ -4111,7 +4172,7 @@ class Array[unchecked out E] < Object
|
|
|
4111
4172
|
#
|
|
4112
4173
|
# Related: see [Methods for Combining](rdoc-ref:Array@Methods+for+Combining).
|
|
4113
4174
|
#
|
|
4114
|
-
def |: [T] (
|
|
4175
|
+
def |: [T] (array[T] other_array) -> Array[E | T] # where E: _Eql?[T]
|
|
4115
4176
|
|
|
4116
4177
|
private
|
|
4117
4178
|
|
|
@@ -4130,13 +4191,15 @@ class Array[unchecked out E] < Object
|
|
|
4130
4191
|
#
|
|
4131
4192
|
# Related: see [Methods for Assigning](rdoc-ref:Array@Methods+for+Assigning).
|
|
4132
4193
|
#
|
|
4133
|
-
|
|
4194
|
+
alias initialize_copy replace
|
|
4134
4195
|
end
|
|
4135
4196
|
|
|
4197
|
+
%a{deprecated: Use Array::_Rand, or make your own}
|
|
4136
4198
|
interface _Rand
|
|
4137
|
-
def rand: (
|
|
4199
|
+
def rand: (Integer max) -> Integer
|
|
4138
4200
|
end
|
|
4139
4201
|
|
|
4202
|
+
%a{deprecated: Use RBS::Ops::_CaseEqual[E, boolish]}
|
|
4140
4203
|
interface Array::_Pattern[T]
|
|
4141
4204
|
def ===: (T) -> bool
|
|
4142
4205
|
end
|