Created
January 27, 2021 20:20
-
-
Save paulmwatson/a9db1333fcafd59cd17f9d3be2ee141e to your computer and use it in GitHub Desktop.
Ruby 3 RBS dynamic typing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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