Did you have any particular reason for doing so, or was it a mere whim?
It was not strictly on the way, but it seemed clear to Harry that this was a whim on which he should act, so he di-rected his feet immediately toward the vegetable patch, where he was pleased, but not altogether surprised, to find Professor Slughorn in conversation with Professor Sprout.
There are no more uses of "whim" in the book.
Show samples from other sources
They flew to Paris on a whim.
This is the devilish thing about foreign affairs: they are foreign and will not always conform to our whim.