“Type hints” syntax suggestion for Ruby
According to previous note on interfaces in dynamically typed languages, it would be great if the API could specify type expectations even easier than a to_type message send to each argument in method body.
class Person
def initialize(name.to_s, birthday.to_date = DEFAULT_DATE)
...
end
end
Should be interpreted as:
class Person
def initialize(*args)
args.size == 2 or raise ArgumentError
name = args[0].to_s
birthday = (args[1] || DEFAULT_DATE).to_date
...
end
end
This idea can be applied to other languages as well.
