|
1 |
| -*vim9class.txt* For Vim version 9.1. Last change: 2024 Jan 12 |
| 1 | +*vim9class.txt* For Vim version 9.1. Last change: 2024 Mar 03 |
2 | 2 |
|
3 | 3 |
|
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar
|
@@ -710,6 +710,32 @@ The initialization isn't needed, the list is empty by default.
|
710 | 710 | *E1330*
|
711 | 711 | Some types cannot be used, such as "void", "null" and "v:none".
|
712 | 712 |
|
| 713 | +Builtin Object Methods ~ |
| 714 | + *builtin-object-methods* |
| 715 | +Some of the builtin functions like |empty()|, |len()| and |string()| can be |
| 716 | +used with an object. An object can implement a method with the same name as |
| 717 | +these builtin functions to return an object-specific value. |
| 718 | + |
| 719 | + *E1412* |
| 720 | +The following builtin methods are supported: |
| 721 | + *object-empty()* |
| 722 | + empty() Invoked by the |empty()| function to check whether an object is |
| 723 | + empty. If this method is missing, then true is returned. This |
| 724 | + method should not accept any arguments and must return a boolean. |
| 725 | + *object-len()* |
| 726 | + len() Invoked by the |len()| function to return the length of an |
| 727 | + object. If this method is missing in the class, then an error is |
| 728 | + given and zero is returned. This method should not accept any |
| 729 | + arguments and must return a number. |
| 730 | + *object-string()* |
| 731 | + string() Invoked by the |string()| function to get a textual |
| 732 | + representation of an object. Also used by the |:echo| command |
| 733 | + for an object. If this method is missing in the class, then a |
| 734 | + built-in default textual representation is used. This method |
| 735 | + should not accept any arguments and must return a string. |
| 736 | + |
| 737 | + *E1413* |
| 738 | +A class method cannot be used as a builtin method. |
713 | 739 |
|
714 | 740 | Defining an interface ~
|
715 | 741 | *Interface* *:interface* *:endinterface*
|
|
0 commit comments