It's not always a good thing, but I love Ruby's ability to define new runtime-valid syntax that looks pretty much native to Ruby itself.
def method(thing: String | "default value")
the pipe operator seems to be defined here, as just a regular method: https://codeberg.org/Iow/type/src/commit/aaa079bf3dd2ac6b471... the type gets picked out by the module included in the class you want typechecked, which reads the default value from all methods (which is the "real" ruby syntax here, where `thing` is assigned a default value of the result of calling `String | "default value"`) and uses that for type checking.
I like that over-flexibility... it's regularly too clever and makes it difficult to follow the flow of an application, but I like it all the same.
graypegg•17m ago
I like that over-flexibility... it's regularly too clever and makes it difficult to follow the flow of an application, but I like it all the same.