Fixing a variable

Here it is mentioned fixing a variable is better than adding a constraint:

Does JuMP.fix and setting bounds on variables work with vectors or loop is necessary? I have only managed it with a loop:

for i = 15:25
JuMP.fix(x[i], 1,force=true)

You can use standard Julia broadcasting (with some exceptions):

model = Model()
@variable(model, x[1:4])
fix.(x, [1, 2, 3, 4])

But there is nothing wrong with using a for-loop.

Thanks. Using broadcasting syntax, the code runs marginally faster than the loop.