integral over a measurable set
Often you want the area under f only over part of the space — say over a region E rather than everything. The clean Lebesgue trick is to multiply f by the indicator of E, a switch that is 1 on E and 0 off it, and integrate over the whole space. Outside E the integrand is zero and contributes nothing; inside E it is just f. So restriction is just multiplication by a switch.
Precisely, for a measurable set E and a function f for which it makes sense, the integral of f over E is defined as the integral over the whole space of f times the indicator of E. Equivalently one integrates the restriction of f to E against the measure restricted to E. The set function that sends E to the integral of f over E is countably additive: splitting E into disjoint measurable pieces splits the integral as a sum.
This packaging makes many manipulations effortless: integrals over the union of disjoint sets add; integrals over nested shrinking sets behave continuously; and the absolute continuity of the integral says exactly that this set function is small on small-measure sets. It is also the bridge to viewing the integral of a fixed f as a (signed) measure in its own right.
For f(x) = x on [0,2] and E = [0,1], the integral over E is the integral of x times the indicator of [0,1], i.e. the integral of x over [0,1] = 1/2; the part over [1,2] is simply switched off.
Restricting an integral via the indicator switch.