You've just finished a strenuous exercise session, and now you're starving. You have a decision to make: Do you choose a piece of fruit, or do you reward yourself with something decadently delicious, like chocolate? Your choice may come down to when you make it, a University of Nebraska study finds.

Researchers asked two groups of people to do their normal workout routines wearing motion-tracking accelerometers, telling them the equipment needed calibrating.

Your post-exercise snack can undo the gains you made from exercising if you don't plan ahead.

Before exercising, the people in one group were offered a reward after their workout for calibrating the accelerometer they were wearing. They could choose between an apple, a brownie or no snack. The other group of exercisers was presented with the same rewards, but the offer came after they had finished exercising.

Among those who were asked to choose their reward before exercising, about 74 percent picked the apple and 14 percent opted for the brownie. Only 55 percent of the people selecting their snack after they completed their workout chose an apple, and 20 percent picked the brownie.

Decisions made impulsively, on the spot, are more likely to lead to unhealthy choices, as this and other studies have found. The takeaway here is that your post-exercise snack can undo the gains you made from exercising if you don't plan ahead. So especially if weight loss is your goal, it pays to choose your snack before you exercise. Pack a piece of fruit in your bag or a small bag of nuts, and you will be less tempted by unhealthy, high calorie snacks. Chocolate milk makes a good recovery drink, as long as it's low fat and modest in size.

The study is published in Nutrients.