I have two values:
[3:6]
I was trying to play something around in Golang but I can't manage to find a good method to create an array according to those values.
This what I would like to achieve:
[3,4,5,6]
I have two values:
[3:6]
I was trying to play something around in Golang but I can't manage to find a good method to create an array according to those values.
This what I would like to achieve:
[3,4,5,6]
You can make use of the
for ... range
construct to make it more compact and maybe even faster:As a matter of curiosity, the loop can be implemented without a loop variable, but it will be slower, and the code longer. By decrementing
hi
:Or incrementing
lo
: