Skip to content

Instantly share code, notes, and snippets.

@ogaere
Created June 29, 2021 12:02
Show Gist options
  • Save ogaere/cf0c82747152adbfc6f3244616651239 to your computer and use it in GitHub Desktop.
Save ogaere/cf0c82747152adbfc6f3244616651239 to your computer and use it in GitHub Desktop.
Tell me what is wrong with this of code
type Cement struct {
NoOfCement int
}
func (c *Cement) BuyCement(howmany int) {
c.NoOfCement += howmany
}
func (c *Cement) SellCement(howmany int) {
o.NoOfCement -= howmany
}
func (c *Cement) String() string {
return fmt.Sprintf("%v", c.NoOfCement)
}
func main() {
var cement Cement
cement.BuyCement(15)
cement.SellCement(9)
fmt.Println(cement)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment