File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -360,3 +360,31 @@ Modules accessible through ancestors (super-class/included modules) are not supp
360360
361361- Only single module arguments are supported (no ` include A, B` syntax)
362362- Module names must be constants
363+
364+ # # Instance Variables
365+
366+ Inline RBS declaration allows defining instance variables.
367+
368+ ` ` ` ruby
369+ class Person
370+ # @rbs @name: String
371+ # @rbs @age: Integer? --
372+ # how old is the person?
373+ # ` nil ` means it's unspecified.
374+
375+ # @rbs (String name, Integer? age) -> void
376+ def initialize(name, age)
377+ @name = name
378+ @age = age
379+ end
380+ end
381+ ` ` `
382+
383+ The ` @rbs @VAR-NAME: TYPE` syntax enclosed in ` class` / ` module` syntax declares instance variables.
384+ You can add the documentation of the variable followed by two hyphones (` --` ).
385+
386+ Instance variable declarations must be under the ` class` / ` module` syntax, and they are ignored if written inside method definitions.
387+
388+ # ## Current Limitations
389+
390+ - Only instance variables of class / module instances are allowed
You can’t perform that action at this time.
0 commit comments