Feature #17848
closedinline rbs either by rdoc comments or changing syntax
Description
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
Updated by matz (Yukihiro Matsumoto) almost 3 years ago
- 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.
Updated by ko1 (Koichi Sasada) over 2 years ago
- Status changed from Closed to Rejected