Home Segments Index Top Previous Next

554: Mainline

Next, you define an addition method that adds Weight instances. That new method works by first adding the magnitudes and then creating a new instance with the sum as that new instance's magnitude:

Weight method definition • instance 
+ aWeight 
  ^ (self magnitude + aWeight magnitude) gm