I have been trying to access a variable from inside a function and am struggling to find a way to do so.
Below is an idea of what I am trying to achieve. For example, when the function testFunc is run, it will shuffle an array. I want to get the result of that array back into the body of the struct, but am struggling to do so.
Some ideas I have tried include binding variables but it seems gets confusing as I am relatively inexperienced. Is there a method to achieve this or would using the binding variables be the best way to go?
Any help would be greatly appreciated. Thank you!
struct ContentView: View {
var body: some View {
testFunc()
}
func testFunc() {
var tester = ["a", "b", "c"].shuffled
}
}