From: matz@... Date: 2021-05-05T13:58:34+00:00 Subject: [ruby-core:103740] [Ruby master Feature#17848] inline rbs either by rdoc comments or changing syntax Issue #17848 has been updated by matz (Yukihiro Matsumoto). Status changed from Open to Closed Ruby is not going to add new syntax for type annotation. Allowing `yard` comments in RBS syntax may be a (good) choice, but it's up to `yard` side. Matz. ---------------------------------------- Feature #17848: inline rbs either by rdoc comments or changing syntax https://bugs.ruby-lang.org/issues/17848#change-91835 * Author: dsisnero (Dominic Sisneros) * Status: Closed * Priority: Normal ---------------------------------------- I like gradual typing - I like the syntax of rbs files but for coding - convenience it would be nice if we had inline syntax for types. I know that steep allows you to define types inline but because it is valid ruby syntax - the code is not as nice as rbs could we change method arguments syntax to allow rbs type def initialize(from: User | Bot = User.new, string: String = "I got your message") -> void # I know this has to be fleshed out to handle all cases (positional , keyword, default but there should be some way we can do it inline) Either that or bless (recommend) yard style annotations so it is inline and still has easy syntax class Message attr_reader id: String attr_reader string: String attr_reader from: User | Bot # `|` means union types: `#from` can be `User` or `Bot` attr_reader reply_to: Message? # `?` means optional type: `#reply_to` can be `nil` def initialize: (from: User | Bot, string: String) -> void def reply: (from: User | Bot, string: String) -> Message end -- https://bugs.ruby-lang.org/ Unsubscribe: