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 Personal Trusted User Create template Templates let you quickly answer FAQs or store snippets for re-use. Submit Preview Dismiss Code of Conduct • Report abuse Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well Confirm For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)