Skip to content

Commit 07afd04

Browse files
committed
book: let grow() accept the growth parameter
1 parent 557d434 commit 07afd04

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/doc/trpl/method-syntax.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,16 @@ impl Circle {
100100
std::f64::consts::PI * (self.radius * self.radius)
101101
}
102102
103-
fn grow(&self) -> Circle {
104-
Circle { x: self.x, y: self.y, radius: (self.radius * 10.0) }
103+
fn grow(&self, increment: f64) -> Circle {
104+
Circle { x: self.x, y: self.y, radius: self.radius + increment }
105105
}
106106
}
107107
108108
fn main() {
109109
let c = Circle { x: 0.0, y: 0.0, radius: 2.0 };
110110
println!("{}", c.area());
111111
112-
let d = c.grow().area();
112+
let d = c.grow(2.0).area();
113113
println!("{}", d);
114114
}
115115
```
@@ -124,7 +124,7 @@ fn grow(&self) -> Circle {
124124
```
125125

126126
We just say we're returning a `Circle`. With this method, we can grow a new
127-
circle with an area that's 100 times larger than the old one.
127+
circle to any arbitrary size.
128128

129129
## Static methods
130130

0 commit comments

Comments
 (0)