3 ms·
This looks really cool, and something I've wished had existed in the past. Have you thought of doing unions with a syntax like this, following after languages l
by ezekg 8y ago
This looks really cool, and something I've wished had existed in the past. Have you thought of doing unions with a syntax like this, following after languages like Crystal, TS, Elm, etc?
class A
sig(foo: TrueClass | FalseClass).returns(String)
def bar(foo)
foo.to_s
end
end
The T.any(…) syntax seems very … verbose, for Ruby at least. And Ruby doesn't have a true "boolean" class (it has TrueClass/FalseClass), so that would be riddled everywhere unless you created a boolean type yourself. Same for indifferent hashes, i.e. a hash with keys of type T.any(String, Symbol).