In "The Hobbit", when Gandalf, Bilbo, and the dwarves are captured by goblins in the Misty Mountains, Gandalf uses his whip to create a distraction. He whips the goblins, creating chaos and confusion, and then uses this opportunity to escape with the dwarves. He uses his magic to open a hidden passage that leads them out of the goblins' lair.
It's important to remember that Gandalf is a powerful wizard, and his whip is a magical tool that allows him to perform various actions, including fighting and creating distractions. It's not a simple "beater" but a powerful weapon and a crucial element in his escape.