So far, every property and method we've added to our structs has been freely accessible from anywhere. But that's not always what you want. Sometimes you need to protect certain data from being changed in ways that could break your logic. That's exactly what access control is for. π₯
The Problem Without Access Control
Let's say we're building a guild system for an anime RPG. A guild has a treasury, and members can deposit or withdraw gold β but only through proper channels:
struct GuildTreasury {
var gold = 0






