Skip to content

Commit 42c9678

Browse files
committed
Uupdate document
1 parent 5d8159d commit 42c9678

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/syntax.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,16 @@ An instance variable definition consists of the name of an instance variable and
328328

329329
Method definition has several syntax variations.
330330

331-
You can write `self.` or `self?.` before the name of the method to specify the kind of method: instance, singleton, or both instance and singleton.
331+
You can write `self.` or `self?.` before the name of the method to specify the kind of method: instance, singleton, or module function.
332332

333333
```
334334
def to_s: () -> String # Defines a instance method
335335
def self.new: () -> AnObject # Defines singleton method
336336
def self?.sqrt: (Numeric) -> Numeric # self? is for `module_function`s
337337
```
338338

339+
`self?` method definition adds two methods: a public singleton method and a private instance method, which is equivalent to `module_function` in Ruby.
340+
339341
The method type can be connected with `|`s to define an overloaded method.
340342

341343
```
@@ -404,7 +406,7 @@ alias collect map # `#collect` has the same ty
404406

405407
### `public`, `private`
406408

407-
`public` and `private` allows specifying the visibility of methods.
409+
`public` and `private` allows specifying the visibility of instance methods.
408410

409411
These work only as _statements_, not per-method specifier.
410412

0 commit comments

Comments
 (0)