The court heard how the gobstopper was as big as a snooker ball
A man caught carrying a large gobstopper in a sock has been fined £400 after it was found to be an offensive weapon.
Jamie Harvey, 20, said he needed it for protection after he was attacked.
At Edinburgh Sheriff Court he admitted carrying the snooker ball-sized gobstopper and sock at a city leisure centre on 19 December last year.
Defence agent Matthew Nicholson said the sweet was "a substantial piece of confectionary" which could be eaten.
The court heard how unemployed Harvey, from the Maybury area of Edinburgh, kept the gobstopper under his car seat.
He was caught at Drumbrae Leisure Centre by police who were searching for cannabis.
Sheriff Kenneth McIver told him that, even though it was not in the same category as a knife or axe, it was capable of inflicting a nasty injury.
"You will be aware of the ongoing national debate on offensive weapons including knives," he told Harvey.
"But all too often this court has to consider other improvised weapons like this."