Skip to content

Instantly share code, notes, and snippets.

@paulmwatson
Created January 27, 2021 20:20
Show Gist options
  • Save paulmwatson/a9db1333fcafd59cd17f9d3be2ee141e to your computer and use it in GitHub Desktop.
Save paulmwatson/a9db1333fcafd59cd17f9d3be2ee141e to your computer and use it in GitHub Desktop.
Ruby 3 RBS dynamic typing
#main.rb
class Super
def initialize(val)
@val = val
end
def val?
@val
end
end
class Test < Super
def initialize(val, flag: true)
super(val)
@flag = flag
end
def flag?
@flag
end
end
#main.rbs
class Super
attr_reader val : Integer
def initialize : (val: Integer) -> void
end
class Test < Super
attr_reader flag : bool
def initialize : (val: Integer, ?flag: bool) -> void
def flag? : () -> bool
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment