Comment by jrochkind1

15 hours ago

Wait, what happens if you want keyword arguments?

Their docs say that something like:

`def greet(name: String, greeting: String = "Hello"): String`

will work for kwargs with default values — https://type-ruby.github.io/docs/getting-started/understandi...

  • I think they've missed a trick there, they could have used `|` like low-type does.

    e.g.

      def greet(name: String | "Hello"): String
    

    I know it's all subjective but I think that reads better and it's valid ruby.

    To be honest low-type with a static analysis tool would be my favourite syntax for this.

    https://github.com/low-rb/low_type

Yeah, it doesn't work with keyword arguments. In the playground I tried a simple keyword with default value, and it converted to the wrong thing, as if "someone" was a valid type.

    def greet(name: "someone"): String
      "Hello, #{name}!"
    end

The obvious thing that comes to mind when looking at their spotlight example.

However, no mention of this basic head scratcher in the docs. :rolling_eyes: