File tree 1 file changed +4
-2
lines changed
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -328,14 +328,16 @@ An instance variable definition consists of the name of an instance variable and
328
328
329
329
Method definition has several syntax variations.
330
330
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 .
332
332
333
333
```
334
334
def to_s: () -> String # Defines a instance method
335
335
def self.new: () -> AnObject # Defines singleton method
336
336
def self?.sqrt: (Numeric) -> Numeric # self? is for `module_function`s
337
337
```
338
338
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
+
339
341
The method type can be connected with ` | ` s to define an overloaded method.
340
342
341
343
```
@@ -404,7 +406,7 @@ alias collect map # `#collect` has the same ty
404
406
405
407
### ` public ` , ` private `
406
408
407
- ` public ` and ` private ` allows specifying the visibility of methods.
409
+ ` public ` and ` private ` allows specifying the visibility of instance methods.
408
410
409
411
These work only as _ statements_ , not per-method specifier.
410
412
You can’t perform that action at this time.
0 commit comments