I have a ForEach loop which works with index, how I can make this ForEach step get custom step, because in ForEach in every single loop, it will add one to index, how we cam make step be 5, it means in every single loop adds 5 instead 1. I can make it possible with if and %, but I do not want ForEach try every each Item inside Items. how we can make it efficient coding?
Code:
struct ContentView: View
{
var body: some View
{
List
{
ForEach(0 ..< 21) { index in // (Step == 5) not 1
Text("Hello, world!")
.padding()
}
}
}
}