Skip to content

Commit

Permalink
doc: Add declaration of method annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Nov 25, 2024
1 parent 6037b0c commit fcb9183
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions manual/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,25 @@ This annotation tells instance variable of instance.
* `@type` `instance` `ivar` *ivar* `:` *type*
* `@type` `module` `ivar` *ivar* `:` *type*

## Method Annotations

Method annotations are about hinting behavior of the method.

This kind of annotations should be written in the method context using annotation notation (ex. `%a{...}`) in the RBS file.

Supported annotations are:

* `pure`: This method is a pure method. It means this method do not have side effects, and its return type will not be changed during the conditional block.

### Example

```rbs
class Foo
%a{pure}
def foo: () -> String
end
```

## Type assertion

Type assertion allows declaring type of an expression inline, without introducing new local variable with variable type annotation.
Expand Down

0 comments on commit fcb9183

Please sign in to comment.