3 ms·
That seems very Ruby to me: sig { params(x: Integer).returns(String) } I can read it outloud: Signature is defined as: one parameter called x of type Inte
by gls2ro 2y ago
That seems very Ruby to me:
sig { params(x: Integer).returns(String) }
I can read it outloud:
Signature is defined as: one parameter called x of type Integer and will return a String.
Sorbet may have some warts, but the example you show is simple and easy to understand.
The `sig` is as Ruby as you get IMO:
class MyTest
extend T::Sig
end
MyTest.method(:sig).source_location
=> ["...gem/ruby/3.3.4/gems/sorbet-runtime-0.5.11495/lib/types/sig.rb", 27]
And when opening that file we can get something like:
def sig(arg0=nil, &blk)
T::Private::Methods.declare_sig(self, Kernel.caller_locations(1, 1)&.first, arg0, &blk)
end
I do agree about RBS being separate files that is something that can stop a coding flow.