logoalt Hacker News

jrochkind1today at 2:19 AM5 repliesview on HN

Wait, what happens if you want keyword arguments?


Replies

nitzatoday at 8:05 AM

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...

show 2 replies
anamexistoday at 6:26 AM

It would seem that in T-Ruby all arguments are keyword arguments, although they don’t really spell this out.

https://type-ruby.github.io/docs/learn/functions/optional-re...

Dan42today at 3:57 AM

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
t-writescodetoday at 3:25 AM

keyword arguments are, internally, syntactic sugar over a hash. It probably doesn't easily work with typing the explicit values of a raw hash

show 1 reply
ximustoday at 5:56 AM

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: