Chapter 9 - Defined Types
Exercise 1: Defining Methods
In the last chapter’s exercises, we had you write a rectangleInfo
function that accepted a rectangle
struct value and printed its length
and width
fields. Convert the rectangleInfo
function into an info
method on the rectangle
type.
Solution
Output:
Length: 4.2
Width: 2.3