Files
learngo/interfaces/08-composition/discount.go
2019-08-25 08:57:53 +03:00

18 lines
294 B
Go

package main
// usually: include the discount method in the list.go
// it is here for clarity
// TODO: NEW
func (l list) discount(ratio float64) {
type discounter interface {
discount(float64)
}
for _, it := range l {
if it, ok := it.(discounter); ok {
it.discount(ratio)
}
}
}