Open hariprasadraja opened 2 years ago
This function is intended to generate random numbers between 1 to 5 which will be assigned as priority to the task. Hence the name RandPriority of the function. adding value minPriority again because if I dont do it then priority is ranging between 0 to 5.
what is the role of maxPriority-minPriority+1 ?
maxPrioirty and minPriority are the constants to imply the maximum priority which is 5 and minimum priority which is 1. rand.Intn(maxPriority-minPriority+1) will generate pirority randomly between 1 to 5. I will declare varaibles maxPrioirty and minPriority as constants.
Instead of rand.Intn(5 - 1 + 1)
, why can't you have rand.Intn(5)
func RandPriority() int { return rand.Intn(maxPriority-minPriority+1) + minPriority }
what is the point in subtracting and adding again in the random integer generation ?