Created
June 3, 2018 10:04
-
-
Save kkismd/c69bbe01d428aa651baf89197f33abfe to your computer and use it in GitHub Desktop.
imitate sorbet typecheker
This file contains hidden or 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
#! env ruby | |
class CodeSignature | |
def initialize(args) | |
@args = args | |
end | |
def returns(klass) | |
@ret = klass | |
puts "CodeSignature: @args = #{@args.inspect}" | |
puts "CodeSignature: @ret = #{@ret.inspect}" | |
self | |
end | |
end | |
class Module | |
def sig(args) | |
CodeSignature.new(args) | |
end | |
end | |
class A | |
sig(foo: Integer).returns(String) | |
def bar(foo) | |
foo.to_s | |
end | |
end | |
if $0 == __FILE__ | |
a = A.new | |
a.bar(1) | |
a.bar("hoge") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
RDLだと全部文字列で書くことになる