Mistake: treating a reference type as a value type

Learn about the common mistake of treating a reference type as a value type.

Suppose that a customer enters a supermarket and buys a chewing gum. The customer was also a diligent collector of empty bottles and happened to cash in 4000 bottles in exchange for a 1000€ voucher. The cashier is checking if there are enough funds to accept the payment. This check is performed by the canChange function returning a boolean result:

Get hands-on with 1200+ tech skills courses.