How do you reference the left motor inside the motor array?

Enhance your programming skills with the RECF Programming Test. Features flashcards and multiple choice questions with hints and explanations. Prepare for success!

Multiple Choice

How do you reference the left motor inside the motor array?

Explanation:
Motors are accessed in the motor array by using a port alias as the index. The left motor is given the alias leftMotor, so referencing motor[leftMotor] picks out the left motor specifically. This keeps the code clear and flexible: if the port changes, you only update the alias, not every reference. Referencing motor[rightMotor] would grab the right motor, not the left. Using a raw index like motor[0] relies on a fixed port number and isn’t as readable or maintainable. motor[motorLeft] would work only if there were a separate alias named motorLeft, which isn’t the standard leftMotor alias.

Motors are accessed in the motor array by using a port alias as the index. The left motor is given the alias leftMotor, so referencing motor[leftMotor] picks out the left motor specifically. This keeps the code clear and flexible: if the port changes, you only update the alias, not every reference.

Referencing motor[rightMotor] would grab the right motor, not the left. Using a raw index like motor[0] relies on a fixed port number and isn’t as readable or maintainable. motor[motorLeft] would work only if there were a separate alias named motorLeft, which isn’t the standard leftMotor alias.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy