3 ms·
This is a great write up and I think the proposal to make rbs-inline type comments avaible at runtime is an execellent solution. I can definitely see the value
by Lio 1y ago
This is a great write up and I think the proposal to make rbs-inline type comments avaible at runtime is an execellent solution.
I can definitely see the value runtime type checking in addition to static analysis. For my own work I've done this either using pattern matching:
class User
def initialize(name:, age:)
String => name
Integer => age
@name = name
@age = age
end
end
but the error messages aren't great IMHO. It's pretty easy though knock up a little type checker in a very small module and prepend it. I have support for union types and typed arrays in mine.
I actually wasn't aware of the improvements they've made over the years to Sorbet. It think that's probably what I'll migrate to now.
- Lio 1y agoI'd add, I'm surprised this this post isn't added to the "official" Sorbet blog. It really is a great post and very positive for the future of the project. https://sorbet.org/blog/ https://sorbet.org/blog/