Skip to content

Commit

Permalink
feat(Object Orientation): 完成面向对象章节方法部分
Browse files Browse the repository at this point in the history
  • Loading branch information
juzi214032 committed Aug 3, 2020
1 parent 5637584 commit 4838c93
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/language-specification/object-orientation.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,8 @@ def person7 = new PersonWOConstructor(name: 'Marie', age: 2) // 注释 5
- 当没有声明(或无参数)构造函数时,Groovy 会用调用无参数构造函数来代替命名构造函数的调用,然后再调用每个提供的命名属性的 setter
- 当第一个参数是 Map 时,Groovy 会将所有命名的参数合并成一个 Map(不考虑顺序),并将 Map 作为第一个参数提供。如果你的属性被声明为 `final`(因为它们将在构造函数中设置,而不是在事后用 setter 设置),这可能是一个好方法。
- 你可以通过提供位置构造函数以及 no-arg 或 Map 构造函数来支持命名和位置构造。
- 你可以通过使用一个构造函数来支持混合构造,在这个构造函数中,第一个参数是一个 Map,但也有额外的位置参数。请谨慎使用这种风格。
- 你可以通过使用一个构造函数来支持混合构造,在这个构造函数中,第一个参数是一个 Map,但也有额外的位置参数。请谨慎使用这种风格。

### 1.5 方法

Groovy 的方法和其他语言非常相似。一些特别的地方会在接下来的小节中讲解。

0 comments on commit 4838c93

Please sign in to comment.