# Conditions in SparseArray

I got confused by {i_, j_} /; in the following code. I didn't see an explanation in the SparseArray documentation. Can anyone tell me how this part work in the code?

m1 = SparseArray[{{i_, i_} -> -2, {i_, j_} /; Abs[i - j] == 1 -> 1}, {5, 5}];

-

{i_, j_} /; Abs[i - j] == 1 is a pattern. It matches pairs of expressions the difference of which is 1.

/; is Condition.

In SparseArray this will put a 1 on the second diagonals, as the difference of the indices of elements on the second diagonals is 1 or -1.

-
@Szaolcs Thanks a lot! – Lawerance Jul 26 '14 at 18:21