## Trying to apply what I've learned elsewhere with no luck

 Oct '23 So, we have done so many functions that I thought I could pull this off. I am helping my students create an app that will track their goals/scores on a test. They would put in their goal and then their score when the test was complete. I want that double to give me my trim value. I really thought I could pull what we did from Cupcake Corner to make this happen, but I'm floundering. struct MMathView: View { ``````@AppStorage("mapBOY") var mapBOY: Int = 0 @AppStorage("mapBOYg") var mapBOYg: Int = 0 var setTrim: Double { var setTrim = Double(mapBOY/mapBOYg) return setTrim } func setTrim() -> Double { return Double(mapBOY/mapBOYg) let result = setTrim() }`````` ///// later I use it here `````` Circle()// Beginning band-goal .trim(from: 0, to: setTrim) .stroke(lineWidth: 40) .frame(width: 450) .rotationEffect(.init(degrees: -90))`````` So it should fill it to 0.8 but it doesn't change the value at all. If I switch the values, I do get a full fill so the trim seems to be getting a value... just not the right way? 3 Oct '23 Integer division throws away any remainder, so, depending on the values you feed it, your `mapBOY/mapBOYg` is often going to end up as `0`. Which when you convert to a `Double`, becomes `0.0`. As in the example where you are expecting `0.8`; you will never get that as an answer when converting the result of integer division to a `Double`. 4 Oct '23 As @roosterboy says is true change the computed property to this ``````var setTrim: Double { Double(mapBOY) / Double(mapBOYg) }`````` So you can do this ``````struct ContentView: View { @AppStorage("mapBOY") var mapBOY: Int = 8 @AppStorage("mapBOYg") var mapBOYg: Int = 10 var setTrim: Double { Double(mapBOY) / Double(mapBOYg) } var body: some View { ZStack { Circle() .stroke(Color.blue.opacity(0.2), style: StrokeStyle(lineWidth: 40, lineCap: .round)) .frame(width: 300) .rotationEffect(.init(degrees: -90)) Circle() .trim(from: 0.0, to: setTrim) .stroke(Color.blue.gradient, style: StrokeStyle(lineWidth: 40, lineCap: .round)) .frame(width: 300) .rotationEffect(.init(degrees: -90)) } } }`````` 4 Oct '23 Thank yall! I appreciate it. Order of operations got me! 3

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until July 28th.

Sponsor Hacking with Swift and reach the world's largest Swift community!