سؤال

Which would you do:

setter(index, value)

or

setter(value, index)
هل كانت مفيدة؟

المحلول

I would say the first. I normally put the high level argument first, i.e. the index decides where to place the value in.

From a computer's perspective: first you need the location of where to store, when that is found, the value can be set.

It is similar as setting a property of e.g. an element of a car:

SetWheelDiameter(CarModel model, Part.Wheels, Wheel.Diameter, 19.0) Parameters are from high level to low level.

نصائح أخرى

Googling:

"T value int index"

suggests that it is a lot more common than:

"int index T value"
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top