func (a *ArithCommand) subtract() int { if len(a.flags.Args()) > 3 { panic("Oops, I can only subtract 2 numbers!") } args := a.flags.Args()[1:3] ret := utils.StrArrToIntArr(args) difference := ret[0] - ret[1] fmt.Println(difference) return difference }
func (a *ArithCommand) add() int { args := a.flags.Args()[1 : len(a.flags.Args())-1] fmt.Println(args) sum := 0 //convert string arr to int arr ret := utils.StrArrToIntArr(args) //sum all numbers for _, num := range ret { sum = sum + num } fmt.Println(sum) return sum }