54 lines
1.3 KiB
Markdown
54 lines
1.3 KiB
Markdown
# Exemples / DO-DON'T — Chapitre 15 — Fonctions, méthodes et `clsmethod`
|
|
|
|
> Document compagnon non normatif tant qu'une règle n'est pas explicitement référencée comme normative par le chapitre.
|
|
|
|
## Exemples actuellement présents dans le chapitre
|
|
|
|
### Exemple 1
|
|
|
|
```text
|
|
func fonction libre
|
|
method méthode d'instance
|
|
clsmethod méthode de classe
|
|
operator implémentation d'un contrat opérateur
|
|
```
|
|
|
|
### Exemple 2
|
|
|
|
```text
|
|
opération infaillible
|
|
-> retourne directement T
|
|
|
|
opération pouvant produire une erreur récupérable
|
|
-> retourne Result<T>
|
|
ou Result<T,E>
|
|
```
|
|
|
|
### Exemple 3
|
|
|
|
```text
|
|
method length() -> uint64
|
|
method containsKey(K key) -> bool
|
|
Object::sameInstance(Object other) -> bool
|
|
func min(int32 a, int32 b) -> int32
|
|
```
|
|
|
|
### Exemple 4
|
|
|
|
```text
|
|
func readFile(String path) -> Result<String, IoError>
|
|
method parse(String input) -> Result<Value, ParseError>
|
|
```
|
|
|
|
### Exemple 5
|
|
|
|
```text
|
|
return value;
|
|
return Result::Ok(value);
|
|
return Result::Ok(Void);
|
|
```
|
|
|
|
## DO / DON'T / WHY / compiler error / edge cases
|
|
|
|
La couverture structurée de cette section sera enrichie au fur et à mesure de la fermeture des règles du chapitre. La migration `0.2.12` conserve volontairement les exemples historiques dans le chapitre afin de ne perdre aucun contexte normatif.
|