You could also do something like this, defining a type alias for battery size. Or `BatterySize = distinct int` if you want a type `BatterySize` that is distinct from any other int but still uses an int data type. That means you need to initialize 70 as `70.BatterySize` though, or create a `converter intToBatterySize(x: int): BatterySize = x.BatterySize`. type BatterySize = int ElectricCar = object year: int batterySize: BatterySize var c = ElectricCar(year: 2019, batterySize: 70) echo c.year echo c.batterySize Run
- How to embed objects in another objects SebastianM
- How to embed objects in another objects hugogranstrom
- How to embed objects in another objects SebastianM
- How to embed objects in another objects hugogranstrom
- How to embed objects in another objects kcvinu
- How to embed objects in another object... Araq
- How to embed objects in another ob... kcvinu
- How to embed objects in anothe... SebastianM
- How to embed objects in anothe... PMunch
- How to embed objects in anothe... SebastianM
- How to embed objects in anothe... shirleyquirk
- How to embed objects in anothe... SebastianM