rbs 3.3.2 → 3.4.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/.github/workflows/comments.yml +2 -5
- data/.github/workflows/ruby.yml +7 -8
- data/.github/workflows/typecheck.yml +37 -0
- data/CHANGELOG.md +65 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +11 -11
- data/README.md +1 -0
- data/Rakefile +2 -2
- data/Steepfile +2 -2
- data/core/array.rbs +19 -49
- data/core/basic_object.rbs +2 -2
- data/core/comparable.rbs +17 -8
- data/core/complex.rbs +82 -43
- data/core/data.rbs +2 -4
- data/core/dir.rbs +635 -295
- data/core/enumerable.rbs +11 -18
- data/core/enumerator.rbs +37 -31
- data/core/errors.rbs +4 -0
- data/core/false_class.rbs +34 -15
- data/core/fiber.rbs +23 -0
- data/core/file.rbs +329 -120
- data/core/float.rbs +17 -32
- data/core/gc.rbs +17 -11
- data/core/hash.rbs +22 -44
- data/core/integer.rbs +82 -113
- data/core/io/buffer.rbs +90 -47
- data/core/io.rbs +54 -121
- data/core/kernel.rbs +442 -489
- data/core/match_data.rbs +55 -56
- data/core/module.rbs +45 -1
- data/core/nil_class.rbs +98 -35
- data/core/numeric.rbs +22 -32
- data/core/object_space/weak_key_map.rbs +102 -0
- data/core/process.rbs +1242 -655
- data/core/ractor.rbs +139 -120
- data/core/range.rbs +100 -4
- data/core/rational.rbs +0 -4
- data/core/rbs/unnamed/argf.rbs +16 -8
- data/core/rbs/unnamed/env_class.rbs +0 -24
- data/core/refinement.rbs +8 -0
- data/core/regexp.rbs +1149 -598
- data/core/ruby_vm.rbs +126 -12
- data/core/rubygems/platform.rbs +9 -0
- data/core/rubygems/rubygems.rbs +1 -1
- data/core/rubygems/version.rbs +5 -1
- data/core/set.rbs +20 -22
- data/core/signal.rbs +4 -4
- data/core/string.rbs +283 -230
- data/core/string_io.rbs +2 -14
- data/core/struct.rbs +404 -24
- data/core/symbol.rbs +1 -19
- data/core/thread.rbs +29 -12
- data/core/time.rbs +227 -104
- data/core/trace_point.rbs +2 -5
- data/core/true_class.rbs +54 -21
- data/core/warning.rbs +14 -11
- data/docs/data_and_struct.md +29 -0
- data/docs/gem.md +58 -0
- data/docs/syntax.md +3 -5
- data/docs/tools.md +1 -0
- data/ext/rbs_extension/lexer.c +643 -559
- data/ext/rbs_extension/lexer.re +5 -1
- data/ext/rbs_extension/parser.c +12 -3
- data/ext/rbs_extension/unescape.c +7 -47
- data/lib/rbs/cli/diff.rb +4 -1
- data/lib/rbs/cli/validate.rb +280 -0
- data/lib/rbs/cli.rb +2 -194
- data/lib/rbs/collection/config.rb +5 -6
- data/lib/rbs/collection/sources/git.rb +1 -1
- data/lib/rbs/collection.rb +1 -0
- data/lib/rbs/diff.rb +7 -4
- data/lib/rbs/errors.rb +11 -0
- data/lib/rbs/test/errors.rb +10 -2
- data/lib/rbs/test/guaranteed.rb +2 -3
- data/lib/rbs/test/type_check.rb +15 -10
- data/lib/rbs/test.rb +3 -3
- data/lib/rbs/types.rb +29 -0
- data/lib/rbs/unit_test/convertibles.rb +176 -0
- data/lib/rbs/unit_test/spy.rb +136 -0
- data/lib/rbs/unit_test/type_assertions.rb +341 -0
- data/lib/rbs/unit_test/with_aliases.rb +143 -0
- data/lib/rbs/unit_test.rb +6 -0
- data/lib/rbs/version.rb +1 -1
- data/sig/cli/validate.rbs +43 -0
- data/sig/diff.rbs +3 -1
- data/sig/errors.rbs +8 -0
- data/sig/rbs.rbs +1 -1
- data/sig/test/errors.rbs +52 -0
- data/sig/test/guranteed.rbs +9 -0
- data/sig/test/type_check.rbs +19 -0
- data/sig/test.rbs +82 -0
- data/sig/types.rbs +6 -1
- data/sig/unit_test/convertibles.rbs +154 -0
- data/sig/unit_test/spy.rbs +28 -0
- data/sig/unit_test/type_assertions.rbs +194 -0
- data/sig/unit_test/with_aliases.rbs +136 -0
- data/stdlib/base64/0/base64.rbs +307 -45
- data/stdlib/bigdecimal/0/big_decimal.rbs +35 -15
- data/stdlib/coverage/0/coverage.rbs +2 -2
- data/stdlib/csv/0/csv.rbs +25 -55
- data/stdlib/date/0/date.rbs +1 -43
- data/stdlib/date/0/date_time.rbs +1 -13
- data/stdlib/delegate/0/delegator.rbs +186 -0
- data/stdlib/delegate/0/kernel.rbs +47 -0
- data/stdlib/delegate/0/simple_delegator.rbs +98 -0
- data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -1
- data/stdlib/erb/0/erb.rbs +2 -2
- data/stdlib/fileutils/0/fileutils.rbs +0 -19
- data/stdlib/io-console/0/io-console.rbs +12 -1
- data/stdlib/ipaddr/0/ipaddr.rbs +2 -1
- data/stdlib/json/0/json.rbs +320 -81
- data/stdlib/logger/0/logger.rbs +9 -5
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +6 -6
- data/stdlib/monitor/0/monitor.rbs +78 -0
- data/stdlib/net-http/0/net-http.rbs +1880 -543
- data/stdlib/objspace/0/objspace.rbs +19 -13
- data/stdlib/openssl/0/openssl.rbs +508 -127
- data/stdlib/optparse/0/optparse.rbs +25 -11
- data/stdlib/pathname/0/pathname.rbs +1 -1
- data/stdlib/pp/0/pp.rbs +2 -5
- data/stdlib/prettyprint/0/prettyprint.rbs +2 -2
- data/stdlib/pstore/0/pstore.rbs +2 -4
- data/stdlib/rdoc/0/comment.rbs +1 -2
- data/stdlib/resolv/0/resolv.rbs +4 -2
- data/stdlib/socket/0/socket.rbs +2 -2
- data/stdlib/socket/0/unix_socket.rbs +2 -2
- data/stdlib/strscan/0/string_scanner.rbs +3 -2
- data/stdlib/tempfile/0/tempfile.rbs +1 -1
- data/stdlib/uri/0/common.rbs +245 -123
- metadata +24 -4
- data/lib/rbs/test/spy.rb +0 -6
data/core/float.rbs
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
# should know its esoteric system. See following:
|
|
7
7
|
#
|
|
8
8
|
# * https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
|
|
9
|
-
# * https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ
|
|
10
|
-
#
|
|
9
|
+
# * https://github.com/rdp/ruby_tutorials_core/wiki/Ruby-Talk-FAQ#-why-are-rub
|
|
10
|
+
# ys-floats-imprecise
|
|
11
11
|
# * https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
|
|
12
12
|
#
|
|
13
13
|
#
|
|
@@ -109,8 +109,6 @@ class Float < Numeric
|
|
|
109
109
|
# 10.0 % 4.0 # => 2.0
|
|
110
110
|
# 10.0 % Rational(4, 1) # => 2.0
|
|
111
111
|
#
|
|
112
|
-
# Float#modulo is an alias for Float#%.
|
|
113
|
-
#
|
|
114
112
|
def %: (Integer) -> Float
|
|
115
113
|
| (Float) -> Float
|
|
116
114
|
| (Rational) -> Float
|
|
@@ -181,9 +179,9 @@ class Float < Numeric
|
|
|
181
179
|
|
|
182
180
|
# <!--
|
|
183
181
|
# rdoc-file=numeric.rb
|
|
184
|
-
# - -float
|
|
182
|
+
# - -float -> float
|
|
185
183
|
# -->
|
|
186
|
-
# Returns `
|
|
184
|
+
# Returns `self`, negated.
|
|
187
185
|
#
|
|
188
186
|
def -@: () -> Float
|
|
189
187
|
|
|
@@ -326,16 +324,13 @@ class Float < Numeric
|
|
|
326
324
|
|
|
327
325
|
# <!--
|
|
328
326
|
# rdoc-file=numeric.rb
|
|
329
|
-
# - float.abs
|
|
330
|
-
# - float.magnitude -> float
|
|
327
|
+
# - float.abs -> float
|
|
331
328
|
# -->
|
|
332
|
-
# Returns the absolute value of `
|
|
333
|
-
#
|
|
334
|
-
# (-34.56).abs #=> 34.56
|
|
335
|
-
# -34.56.abs #=> 34.56
|
|
336
|
-
# 34.56.abs #=> 34.56
|
|
329
|
+
# Returns the absolute value of `self`:
|
|
337
330
|
#
|
|
338
|
-
#
|
|
331
|
+
# (-34.56).abs # => 34.56
|
|
332
|
+
# -34.56.abs # => 34.56
|
|
333
|
+
# 34.56.abs # => 34.56
|
|
339
334
|
#
|
|
340
335
|
def abs: () -> Float
|
|
341
336
|
|
|
@@ -481,8 +476,6 @@ class Float < Numeric
|
|
|
481
476
|
# f.quo(Rational(2, 1)) # => 1.57
|
|
482
477
|
# f.quo(Complex(2, 0)) # => (1.57+0.0i)
|
|
483
478
|
#
|
|
484
|
-
# Float#fdiv is an alias for Float#quo.
|
|
485
|
-
#
|
|
486
479
|
def fdiv: (Complex) -> Complex
|
|
487
480
|
| (Numeric) -> Float
|
|
488
481
|
|
|
@@ -630,8 +623,6 @@ class Float < Numeric
|
|
|
630
623
|
# 10.0 % 4.0 # => 2.0
|
|
631
624
|
# 10.0 % Rational(4, 1) # => 2.0
|
|
632
625
|
#
|
|
633
|
-
# Float#modulo is an alias for Float#%.
|
|
634
|
-
#
|
|
635
626
|
def modulo: (Numeric) -> Float
|
|
636
627
|
|
|
637
628
|
# <!--
|
|
@@ -649,9 +640,9 @@ class Float < Numeric
|
|
|
649
640
|
|
|
650
641
|
# <!--
|
|
651
642
|
# rdoc-file=numeric.rb
|
|
652
|
-
# -
|
|
643
|
+
# - negative? -> true or false
|
|
653
644
|
# -->
|
|
654
|
-
# Returns `true` if `
|
|
645
|
+
# Returns `true` if `self` is less than 0, `false` otherwise.
|
|
655
646
|
#
|
|
656
647
|
def negative?: () -> bool
|
|
657
648
|
|
|
@@ -725,9 +716,9 @@ class Float < Numeric
|
|
|
725
716
|
|
|
726
717
|
# <!--
|
|
727
718
|
# rdoc-file=numeric.rb
|
|
728
|
-
# -
|
|
719
|
+
# - positive? -> true or false
|
|
729
720
|
# -->
|
|
730
|
-
# Returns `true` if `
|
|
721
|
+
# Returns `true` if `self` is greater than 0, `false` otherwise.
|
|
731
722
|
#
|
|
732
723
|
def positive?: () -> bool
|
|
733
724
|
|
|
@@ -779,8 +770,6 @@ class Float < Numeric
|
|
|
779
770
|
# f.quo(Rational(2, 1)) # => 1.57
|
|
780
771
|
# f.quo(Complex(2, 0)) # => (1.57+0.0i)
|
|
781
772
|
#
|
|
782
|
-
# Float#fdiv is an alias for Float#quo.
|
|
783
|
-
#
|
|
784
773
|
def quo: (Complex) -> Complex
|
|
785
774
|
| (Numeric) -> Float
|
|
786
775
|
|
|
@@ -875,9 +864,9 @@ class Float < Numeric
|
|
|
875
864
|
|
|
876
865
|
# <!--
|
|
877
866
|
# rdoc-file=numeric.rb
|
|
878
|
-
# -
|
|
867
|
+
# - to_f -> self
|
|
879
868
|
# -->
|
|
880
|
-
#
|
|
869
|
+
# Returns `self` (which is already a Float).
|
|
881
870
|
#
|
|
882
871
|
def to_f: () -> Float
|
|
883
872
|
|
|
@@ -895,8 +884,6 @@ class Float < Numeric
|
|
|
895
884
|
#
|
|
896
885
|
# (0.3 / 0.1).to_i # => 2 (!)
|
|
897
886
|
#
|
|
898
|
-
# Float#to_int is an alias for Float#to_i.
|
|
899
|
-
#
|
|
900
887
|
def to_i: () -> Integer
|
|
901
888
|
|
|
902
889
|
# <!-- rdoc-file=numeric.c -->
|
|
@@ -910,8 +897,6 @@ class Float < Numeric
|
|
|
910
897
|
#
|
|
911
898
|
# (0.3 / 0.1).to_i # => 2 (!)
|
|
912
899
|
#
|
|
913
|
-
# Float#to_int is an alias for Float#to_i.
|
|
914
|
-
#
|
|
915
900
|
alias to_int to_i
|
|
916
901
|
|
|
917
902
|
# <!--
|
|
@@ -994,9 +979,9 @@ class Float < Numeric
|
|
|
994
979
|
|
|
995
980
|
# <!--
|
|
996
981
|
# rdoc-file=numeric.rb
|
|
997
|
-
# -
|
|
982
|
+
# - zero? -> true or false
|
|
998
983
|
# -->
|
|
999
|
-
# Returns `true` if `
|
|
984
|
+
# Returns `true` if `self` is 0.0, `false` otherwise.
|
|
1000
985
|
#
|
|
1001
986
|
def zero?: () -> bool
|
|
1002
987
|
end
|
data/core/gc.rbs
CHANGED
|
@@ -44,21 +44,27 @@ module GC
|
|
|
44
44
|
|
|
45
45
|
# <!--
|
|
46
46
|
# rdoc-file=gc.rb
|
|
47
|
-
# -
|
|
48
|
-
# - ObjectSpace.garbage_collect -> nil
|
|
49
|
-
# - include GC; garbage_collect -> nil
|
|
50
|
-
# - GC.start(full_mark: true, immediate_sweep: true) -> nil
|
|
51
|
-
# - ObjectSpace.garbage_collect(full_mark: true, immediate_sweep: true) -> nil
|
|
52
|
-
# - include GC; garbage_collect(full_mark: true, immediate_sweep: true) -> nil
|
|
47
|
+
# - start(full_mark: true, immediate_mark: true, immediate_sweep: true)
|
|
53
48
|
# -->
|
|
54
49
|
# Initiates garbage collection, even if manually disabled.
|
|
55
50
|
#
|
|
56
|
-
#
|
|
51
|
+
# The `full_mark` keyword argument determines whether or not to perform a major
|
|
52
|
+
# garbage collection cycle. When set to `true`, a major garbage collection cycle
|
|
53
|
+
# is ran, meaning all objects are marked. When set to `false`, a minor garbage
|
|
54
|
+
# collection cycle is ran, meaning only young objects are marked.
|
|
57
55
|
#
|
|
58
|
-
#
|
|
56
|
+
# The `immediate_mark` keyword argument determines whether or not to perform
|
|
57
|
+
# incremental marking. When set to `true`, marking is completed during the call
|
|
58
|
+
# to this method. When set to `false`, marking is performed in steps that is
|
|
59
|
+
# interleaved with future Ruby code execution, so marking might not be completed
|
|
60
|
+
# during this method call. Note that if `full_mark` is `false` then marking will
|
|
61
|
+
# always be immediate, regardless of the value of `immediate_mark`.
|
|
59
62
|
#
|
|
60
|
-
#
|
|
61
|
-
#
|
|
63
|
+
# The `immedate_sweep` keyword argument determines whether or not to defer
|
|
64
|
+
# sweeping (using lazy sweep). When set to `true`, sweeping is performed in
|
|
65
|
+
# steps that is interleaved with future Ruby code execution, so sweeping might
|
|
66
|
+
# not be completed during this method call. When set to `false`, sweeping is
|
|
67
|
+
# completed during the call to this method.
|
|
62
68
|
#
|
|
63
69
|
# Note: These keyword arguments are implementation and version dependent. They
|
|
64
70
|
# are not guaranteed to be future-compatible, and may be ignored if the
|
|
@@ -258,7 +264,7 @@ module GC
|
|
|
258
264
|
end
|
|
259
265
|
|
|
260
266
|
# <!-- rdoc-file=gc.c -->
|
|
261
|
-
#
|
|
267
|
+
# Internal constants in the garbage collector.
|
|
262
268
|
#
|
|
263
269
|
GC::INTERNAL_CONSTANTS: Hash[Symbol, Integer]
|
|
264
270
|
|
data/core/hash.rbs
CHANGED
|
@@ -247,7 +247,7 @@
|
|
|
247
247
|
# alias eql? ==
|
|
248
248
|
#
|
|
249
249
|
# def hash
|
|
250
|
-
# @author
|
|
250
|
+
# [self.class, @author, @title].hash
|
|
251
251
|
# end
|
|
252
252
|
# end
|
|
253
253
|
#
|
|
@@ -345,6 +345,10 @@
|
|
|
345
345
|
# Note that setting the default proc will clear the default value and vice
|
|
346
346
|
# versa.
|
|
347
347
|
#
|
|
348
|
+
# Be aware that a default proc that modifies the hash is not thread-safe in the
|
|
349
|
+
# sense that multiple threads can call into the default proc concurrently for
|
|
350
|
+
# the same key.
|
|
351
|
+
#
|
|
348
352
|
# ### What's Here
|
|
349
353
|
#
|
|
350
354
|
# First, what's elsewhere. Class Hash:
|
|
@@ -412,7 +416,7 @@
|
|
|
412
416
|
# * #<=: Returns whether `self` is a subset of a given object.
|
|
413
417
|
# * #==: Returns whether a given object is equal to `self`.
|
|
414
418
|
# * #>: Returns whether `self` is a proper superset of a given object
|
|
415
|
-
# * #>=: Returns whether `self` is a
|
|
419
|
+
# * #>=: Returns whether `self` is a superset of a given object.
|
|
416
420
|
#
|
|
417
421
|
#
|
|
418
422
|
# #### Methods for Fetching
|
|
@@ -499,6 +503,12 @@
|
|
|
499
503
|
class Hash[unchecked out K, unchecked out V] < Object
|
|
500
504
|
include Enumerable[[ K, V ]]
|
|
501
505
|
|
|
506
|
+
interface _Key
|
|
507
|
+
def hash: () -> Integer
|
|
508
|
+
|
|
509
|
+
def eql?: (untyped rhs) -> boolish
|
|
510
|
+
end
|
|
511
|
+
|
|
502
512
|
# <!--
|
|
503
513
|
# rdoc-file=hash.c
|
|
504
514
|
# - Hash[] -> new_empty_hash
|
|
@@ -646,8 +656,6 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
646
656
|
# - hash[key] = value -> value
|
|
647
657
|
# - hash.store(key, value)
|
|
648
658
|
# -->
|
|
649
|
-
# Hash#store is an alias for Hash#[]=.
|
|
650
|
-
#
|
|
651
659
|
# Associates the given `value` with the given `key`; returns `value`.
|
|
652
660
|
#
|
|
653
661
|
# If the given `key` exists, replaces its value with the given `value`; the
|
|
@@ -674,6 +682,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
674
682
|
# -->
|
|
675
683
|
# Returns `true` if any element satisfies a given criterion; `false` otherwise.
|
|
676
684
|
#
|
|
685
|
+
# If `self` has no element, returns `false` and argument or block are not used.
|
|
686
|
+
#
|
|
677
687
|
# With no argument and no block, returns `true` if `self` is non-empty; `false`
|
|
678
688
|
# if empty.
|
|
679
689
|
#
|
|
@@ -690,6 +700,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
690
700
|
# h.any? {|key, value| value < 3 } # => true
|
|
691
701
|
# h.any? {|key, value| value > 3 } # => false
|
|
692
702
|
#
|
|
703
|
+
# Related: Enumerable#any?
|
|
704
|
+
#
|
|
693
705
|
def any?: () -> bool
|
|
694
706
|
| (untyped pattern) -> bool
|
|
695
707
|
| () { (K, V) -> boolish } -> bool
|
|
@@ -922,8 +934,6 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
922
934
|
def dig: (K, *untyped) -> untyped
|
|
923
935
|
|
|
924
936
|
# <!-- rdoc-file=hash.c -->
|
|
925
|
-
# Hash#each is an alias for Hash#each_pair.
|
|
926
|
-
#
|
|
927
937
|
# Calls the given block with each key-value pair; returns `self`:
|
|
928
938
|
# h = {foo: 0, bar: 1, baz: 2}
|
|
929
939
|
# h.each_pair {|key, value| puts "#{key}: #{value}"} # => {:foo=>0, :bar=>1, :baz=>2}
|
|
@@ -982,8 +992,6 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
982
992
|
# - hash.each -> new_enumerator
|
|
983
993
|
# - hash.each_pair -> new_enumerator
|
|
984
994
|
# -->
|
|
985
|
-
# Hash#each is an alias for Hash#each_pair.
|
|
986
|
-
#
|
|
987
995
|
# Calls the given block with each key-value pair; returns `self`:
|
|
988
996
|
# h = {foo: 0, bar: 1, baz: 2}
|
|
989
997
|
# h.each_pair {|key, value| puts "#{key}: #{value}"} # => {:foo=>0, :bar=>1, :baz=>2}
|
|
@@ -1127,8 +1135,6 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1127
1135
|
| [X] (*K) { (K) -> X } -> ::Array[V | X]
|
|
1128
1136
|
|
|
1129
1137
|
# <!-- rdoc-file=hash.c -->
|
|
1130
|
-
# Hash#filter is an alias for Hash#select.
|
|
1131
|
-
#
|
|
1132
1138
|
# Returns a new Hash object whose entries are those for which the block returns
|
|
1133
1139
|
# a truthy value:
|
|
1134
1140
|
# h = {foo: 0, bar: 1, baz: 2}
|
|
@@ -1143,8 +1149,6 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1143
1149
|
| () -> ::Enumerator[[ K, V ], ::Hash[K, V]]
|
|
1144
1150
|
|
|
1145
1151
|
# <!-- rdoc-file=hash.c -->
|
|
1146
|
-
# Hash#filter! is an alias for Hash#select!.
|
|
1147
|
-
#
|
|
1148
1152
|
# Returns `self`, whose entries are those for which the block returns a truthy
|
|
1149
1153
|
# value:
|
|
1150
1154
|
# h = {foo: 0, bar: 1, baz: 2}
|
|
@@ -1195,8 +1199,6 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1195
1199
|
| (Integer level) -> Array[untyped]
|
|
1196
1200
|
|
|
1197
1201
|
# <!-- rdoc-file=hash.c -->
|
|
1198
|
-
# Methods #has_key?, #key?, and #member? are aliases for #include?.
|
|
1199
|
-
#
|
|
1200
1202
|
# Returns `true` if `key` is a key in `self`, otherwise `false`.
|
|
1201
1203
|
#
|
|
1202
1204
|
def has_key?: (K arg0) -> bool
|
|
@@ -1206,8 +1208,6 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1206
1208
|
# - hash.has_value?(value) -> true or false
|
|
1207
1209
|
# - hash.value?(value) -> true or false
|
|
1208
1210
|
# -->
|
|
1209
|
-
# Method #value? is an alias for #has_value?.
|
|
1210
|
-
#
|
|
1211
1211
|
# Returns `true` if `value` is a value in `self`, otherwise `false`.
|
|
1212
1212
|
#
|
|
1213
1213
|
def has_value?: (V arg0) -> bool
|
|
@@ -1219,7 +1219,7 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1219
1219
|
# Returns the Integer hash-code for the hash.
|
|
1220
1220
|
#
|
|
1221
1221
|
# Two Hash objects have the same hash-code if their content is the same
|
|
1222
|
-
# (regardless
|
|
1222
|
+
# (regardless of order):
|
|
1223
1223
|
# h1 = {foo: 0, bar: 1, baz: 2}
|
|
1224
1224
|
# h2 = {baz: 2, bar: 1, foo: 0}
|
|
1225
1225
|
# h2.hash == h1.hash # => true
|
|
@@ -1234,8 +1234,6 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1234
1234
|
# - hash.key?(key) -> true or false
|
|
1235
1235
|
# - hash.member?(key) -> true or false
|
|
1236
1236
|
# -->
|
|
1237
|
-
# Methods #has_key?, #key?, and #member? are aliases for #include?.
|
|
1238
|
-
#
|
|
1239
1237
|
# Returns `true` if `key` is a key in `self`, otherwise `false`.
|
|
1240
1238
|
#
|
|
1241
1239
|
alias include? has_key?
|
|
@@ -1245,11 +1243,10 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1245
1243
|
# - hash.inspect -> new_string
|
|
1246
1244
|
# -->
|
|
1247
1245
|
# Returns a new String containing the hash entries:
|
|
1246
|
+
#
|
|
1248
1247
|
# h = {foo: 0, bar: 1, baz: 2}
|
|
1249
1248
|
# h.inspect # => "{:foo=>0, :bar=>1, :baz=>2}"
|
|
1250
1249
|
#
|
|
1251
|
-
# Hash#to_s is an alias for Hash#inspect.
|
|
1252
|
-
#
|
|
1253
1250
|
def inspect: () -> String
|
|
1254
1251
|
|
|
1255
1252
|
# <!--
|
|
@@ -1296,13 +1293,11 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1296
1293
|
# h.key(0) # => :foo
|
|
1297
1294
|
# h.key(2) # => :bar
|
|
1298
1295
|
#
|
|
1299
|
-
# Returns `nil` if
|
|
1296
|
+
# Returns `nil` if no such value is found.
|
|
1300
1297
|
#
|
|
1301
1298
|
def key: (V) -> K?
|
|
1302
1299
|
|
|
1303
1300
|
# <!-- rdoc-file=hash.c -->
|
|
1304
|
-
# Methods #has_key?, #key?, and #member? are aliases for #include?.
|
|
1305
|
-
#
|
|
1306
1301
|
# Returns `true` if `key` is a key in `self`, otherwise `false`.
|
|
1307
1302
|
#
|
|
1308
1303
|
alias key? has_key?
|
|
@@ -1319,15 +1314,12 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1319
1314
|
|
|
1320
1315
|
# <!-- rdoc-file=hash.c -->
|
|
1321
1316
|
# Returns the count of entries in `self`:
|
|
1322
|
-
# {foo: 0, bar: 1, baz: 2}.length # => 3
|
|
1323
1317
|
#
|
|
1324
|
-
#
|
|
1318
|
+
# {foo: 0, bar: 1, baz: 2}.length # => 3
|
|
1325
1319
|
#
|
|
1326
1320
|
def length: () -> Integer
|
|
1327
1321
|
|
|
1328
1322
|
# <!-- rdoc-file=hash.c -->
|
|
1329
|
-
# Methods #has_key?, #key?, and #member? are aliases for #include?.
|
|
1330
|
-
#
|
|
1331
1323
|
# Returns `true` if `key` is a key in `self`, otherwise `false`.
|
|
1332
1324
|
#
|
|
1333
1325
|
alias member? has_key?
|
|
@@ -1394,8 +1386,6 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1394
1386
|
#
|
|
1395
1387
|
# Each argument in `other_hashes` must be a Hash.
|
|
1396
1388
|
#
|
|
1397
|
-
# Method #update is an alias for #merge!.
|
|
1398
|
-
#
|
|
1399
1389
|
# With arguments and no block:
|
|
1400
1390
|
# * Returns `self`, after the given hashes are merged into it.
|
|
1401
1391
|
# * The given hashes are merged left to right.
|
|
@@ -1520,8 +1510,6 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1520
1510
|
# - hash.select {|key, value| ... } -> new_hash
|
|
1521
1511
|
# - hash.select -> new_enumerator
|
|
1522
1512
|
# -->
|
|
1523
|
-
# Hash#filter is an alias for Hash#select.
|
|
1524
|
-
#
|
|
1525
1513
|
# Returns a new Hash object whose entries are those for which the block returns
|
|
1526
1514
|
# a truthy value:
|
|
1527
1515
|
# h = {foo: 0, bar: 1, baz: 2}
|
|
@@ -1539,8 +1527,6 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1539
1527
|
# - hash.select! {|key, value| ... } -> self or nil
|
|
1540
1528
|
# - hash.select! -> new_enumerator
|
|
1541
1529
|
# -->
|
|
1542
|
-
# Hash#filter! is an alias for Hash#select!.
|
|
1543
|
-
#
|
|
1544
1530
|
# Returns `self`, whose entries are those for which the block returns a truthy
|
|
1545
1531
|
# value:
|
|
1546
1532
|
# h = {foo: 0, bar: 1, baz: 2}
|
|
@@ -1575,9 +1561,8 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1575
1561
|
# - hash.size -> integer
|
|
1576
1562
|
# -->
|
|
1577
1563
|
# Returns the count of entries in `self`:
|
|
1578
|
-
# {foo: 0, bar: 1, baz: 2}.length # => 3
|
|
1579
1564
|
#
|
|
1580
|
-
#
|
|
1565
|
+
# {foo: 0, bar: 1, baz: 2}.length # => 3
|
|
1581
1566
|
#
|
|
1582
1567
|
alias size length
|
|
1583
1568
|
|
|
@@ -1594,8 +1579,6 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1594
1579
|
def slice: (*K) -> ::Hash[K, V]
|
|
1595
1580
|
|
|
1596
1581
|
# <!-- rdoc-file=hash.c -->
|
|
1597
|
-
# Hash#store is an alias for Hash#[]=.
|
|
1598
|
-
#
|
|
1599
1582
|
# Associates the given `value` with the given `key`; returns `value`.
|
|
1600
1583
|
#
|
|
1601
1584
|
# If the given `key` exists, replaces its value with the given `value`; the
|
|
@@ -1668,11 +1651,10 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1668
1651
|
|
|
1669
1652
|
# <!-- rdoc-file=hash.c -->
|
|
1670
1653
|
# Returns a new String containing the hash entries:
|
|
1654
|
+
#
|
|
1671
1655
|
# h = {foo: 0, bar: 1, baz: 2}
|
|
1672
1656
|
# h.inspect # => "{:foo=>0, :bar=>1, :baz=>2}"
|
|
1673
1657
|
#
|
|
1674
|
-
# Hash#to_s is an alias for Hash#inspect.
|
|
1675
|
-
#
|
|
1676
1658
|
alias to_s inspect
|
|
1677
1659
|
|
|
1678
1660
|
# <!--
|
|
@@ -1782,8 +1764,6 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1782
1764
|
#
|
|
1783
1765
|
# Each argument in `other_hashes` must be a Hash.
|
|
1784
1766
|
#
|
|
1785
|
-
# Method #update is an alias for #merge!.
|
|
1786
|
-
#
|
|
1787
1767
|
# With arguments and no block:
|
|
1788
1768
|
# * Returns `self`, after the given hashes are merged into it.
|
|
1789
1769
|
# * The given hashes are merged left to right.
|
|
@@ -1828,8 +1808,6 @@ class Hash[unchecked out K, unchecked out V] < Object
|
|
|
1828
1808
|
alias update merge!
|
|
1829
1809
|
|
|
1830
1810
|
# <!-- rdoc-file=hash.c -->
|
|
1831
|
-
# Method #value? is an alias for #has_value?.
|
|
1832
|
-
#
|
|
1833
1811
|
# Returns `true` if `value` is a value in `self`, otherwise `false`.
|
|
1834
1812
|
#
|
|
1835
1813
|
alias value? has_value?
|