A 4-year-old Australian boy learned a valuable lesson from his first experience with a vending machine when his arm became stuck for nearly six hours.

Aaron Shorthouse said his son, Leo, spotted the vending machine at a Melbourne hotel Sunday afternoon and he apparently reached his arm into the machine to try to reach the treats for sale.

"We live up in Arnhem Land, Northern Territory, and I don't think he's seen a vending machine before, so he saw the Oreos, and some biscuits and a few other things," the Australian Broadcasting Corp. quoted Shorthouse as saying.

The 4-year-old's arm became ensnared in the machine's anti-theft mechanism.

Rescuers sedated the boy to keep him calm and distracted him with cartoons played on smartphones while using angle grinders to cut the machine open.

The rescue took more than five hours, but the boy avoided serious injury.

"He's fine after five-and-a-half hours. He was a bit inquisitive, he put his hand in the vending machine, but yes he's good now," Shorthouse said.