You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is called ‘method chaining’, and we can do it by returning self.
The example (copied below) that immediately follows this does not actually contain code returning self. Instead, a new Circle struct is built and returned.
The wording suggests that the next example is going to show how returning self can be done, but the example doesn't show that.
structCircle{x:f64,y:f64,radius:f64,}implCircle{fnarea(&self) -> f64{
std::f64::consts::PI*(self.radius*self.radius)}fngrow(&self,increment:f64) -> Circle{Circle{x:self.x,y:self.y,radius:self.radius + increment }}}fnmain(){let c = Circle{x:0.0,y:0.0,radius:2.0};println!("{}", c.area());let d = c.grow(2.0).area();println!("{}", d);}
The text was updated successfully, but these errors were encountered:
In the method-syntax.md file:
The example (copied below) that immediately follows this does not actually contain code returning self. Instead, a new Circle struct is built and returned.
The wording suggests that the next example is going to show how returning self can be done, but the example doesn't show that.
The text was updated successfully, but these errors were encountered: