Sha256: b697d682610d49d58b971aaf7d906ac12604d8053f7fd4255c58209b54fc3c11

Contents?: true

Size: 1.07 KB

Versions: 18

Compression:

Stored size: 1.07 KB

Contents

def foo(x)
  if x
    42
  else
    "str"
  end
end

foo(true)
foo(false)

# Object#foo :: (Boolean) -> (String | Integer)


# overrided method
def identity(x)
  x
end

identity(42)
identity("str")
identity(:sym)

# Object#identity :: (Integer) -> Integer
# Object#identity :: (String) -> String
# Object#identity :: (Symbol) -> Symbol


# recursive method
def fib(x)
  if x <= 1
    x
  else
    fib(x - 1) + fib(x - 2)
  end
end

fib(40000)

# Object#fib :: (Integer) -> Integer


# user-defined classes
class A
  def foo(x)
    bar(x)
  end

  def bar(x)
  end
end

class B < A
  def bar(x)
  end
end
A.new.foo(1)
B.new.foo("str")

# A#foo :: (Integer) -> NilClass
# A#bar :: (Integer) -> NilClass
# B#foo :: (String) -> NilClass
# B#bar :: (String) -> NilClass

__END__
# Classes
class Object
  def foo : (bool) -> (Integer | String)
  def identity : (:sym | Integer | String) -> (:sym | Integer | String)
  def fib : (Integer) -> Integer
end

class A
  def foo : (Integer | String) -> nil
  def bar : (Integer | String) -> nil
end

class B < A
  def bar : (Integer | String) -> nil
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
typeprof-0.7.0 smoke/demo.rb
typeprof-0.6.1 smoke/demo.rb
typeprof-0.6.0 smoke/demo.rb
typeprof-0.5.4 smoke/demo.rb
typeprof-0.5.3 smoke/demo.rb
typeprof-0.5.2 smoke/demo.rb
typeprof-0.5.1 smoke/demo.rb
typeprof-0.5.0 smoke/demo.rb
typeprof-0.4.2 smoke/demo.rb
typeprof-0.4.1 smoke/demo.rb
typeprof-0.4.0 smoke/demo.rb
typeprof-0.3.0 smoke/demo.rb
typeprof-0.2.0 smoke/demo.rb
typeprof-0.1.4 smoke/demo.rb
typeprof-0.1.3 smoke/demo.rb
typeprof-0.1.2 smoke/demo.rb
typeprof-0.1.1 smoke/demo.rb
typeprof-0.1.0 smoke/demo.rb