hiko1129 Posted on Aug 21, 2022 • Originally published at note.hiko1129.com on Aug 13, 2022 [Ruby][Sorbet] How to write the type of accessor methods (attr_* series methods) #sorbet #ruby #rails Translate ja to en class Hoge sig {returns(String)} # ← このようにattr_系のメソッドの上にsigを書くだけ attr_reader :hoge end Enter fullscreen mode Exit fullscreen mode メソッドコールに対して型定義できるのでそのうちRSpecのletも定義できるような方法が追加されるかも? 参考 https://sorbet.org/docs/faq#how-should-i-add-types-to-methods-defined-with-attr_reader Top comments (0) Subscribe Code of Conduct • Report abuse For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)