Help, struct, init

struct NuclearRocket {
var meters: Double
var liters: Double

init(meters: Double, liters: Double) {
self.meters = meters
self.liters = liters

}

// Init for :us:
init(ft: Double, gallon: Double) {
let convertedMeters = ft / 3.28
let convertedLitter = gallon * 3.78

self.init(meters: convertedMeters, liters: convertedLitter)

}
}

let asdf = NuclearRocket(ft: 1, gallon: 1)
asdf.liters
asdf.meters

thats a.l good for converting feet to metric but how would I switch from metric to feet in the same struct?

Hi @lac_ekim,
I have responded on your other question that you duplicated, so please have a look at that.

cheers,

Jayant

This topic was automatically closed after 166 days. New replies are no longer allowed.