I'm not sure what the correct name for it is (and thus how to search for it), but I was just looking through some go code and saw it organized with statements inside of {}'s. I'm wondering what the reason is for supporting grouping statements like this?
The code looks like this:
// Check horizontal
{
left_to_win := 3
stop_1 := false
stop_2 := false
for x := 1; x <= 4; x++ {
// ....
}
}
// Check vertical
{
left_to_win := 3
stop_1 := false
stop_2 := false
for x := 1; x <= 4; x++ {
// ...
}
}
// Check diagonal bottom to top
{
left_to_win := 3
stop_1 := false
stop_2 := false
for x := 1; x <= 4; x++ {
// ...
}
}
In the specific example it seems like it could easily be refactored into a single utility function. What's the name of this feature, and are there any good examples of times to use it?