Sha256: 6932238bedc5f073b0f13823e2cbd5ea2f285ff93a59ae3747ee2b12bd2f9a47

Contents?: true

Size: 441 Bytes

Versions: 11

Compression:

Stored size: 441 Bytes

Contents

h = { a: :A, b: :B }

def foo(h)
  h.fetch(:a)     #=> :A | :B
end
def bar(h)
  h.fetch(:a, :C) #=> :A | :B | :C
end
def baz(h)
  n = nil
  [h.fetch(:a) do |k| #=> :A | :B | :C
    n = k #=> :A | :B
    :C
  end, n]
end

foo(h)
bar(h)
baz(h)

__END__
# Classes
class Object
  private
  def foo: ({a: :A, b: :B} h) -> (:A | :B)
  def bar: ({a: :A, b: :B} h) -> (:A | :B | :C)
  def baz: ({a: :A, b: :B} h) -> ([:A | :B | :C, (:a | :b)?])
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
typeprof-0.20.0 smoke/hash-fetch.rb
typeprof-0.15.3 smoke/hash-fetch.rb
typeprof-0.15.2 smoke/hash-fetch.rb
typeprof-0.15.1 smoke/hash-fetch.rb
typeprof-0.15.0 smoke/hash-fetch.rb
typeprof-0.14.1 smoke/hash-fetch.rb
typeprof-0.14.0 smoke/hash-fetch.rb
typeprof-0.13.0 smoke/hash-fetch.rb
typeprof-0.12.0 smoke/hash-fetch.rb
typeprof-0.11.0 smoke/hash-fetch.rb
typeprof-0.10.0 smoke/hash-fetch.rb