Let $X$ and $Y$ be iid from $U(0,2)$. What's $E[|−|]$?
I tried simulating the answer, and I got 2/3. I was wondering why this method below, which uses linearity of conditional expectation, doesn't work: \begin{align} E[|X-Y|]&=E[X-Y|X>Y]\\ &=\int_0^2E[X-Y|X>Y,Y=y]f_Y(y)dy\\ &=\frac{1}{2}\int_0^2E[X-Y|X>Y,Y=y]dy\\ &=\frac{1}{2}\int_0^2(E[X|X>Y,Y=y]-E[Y|X>Y,Y=y])dy\\ &=\frac{1}{2}\int_0^2\left(\frac{2+y}{2}-y\right)dy\\ &=1/2. \end{align} Which differs from the correct answer, 2/3.
The problem is with the equation $$E(X-Y\mid X>Y) = \int_0^2 E(X-Y\mid X>Y, Y=y)f_Y(y) dy.$$
Recall that the law of total expectation comes from partitioning the sample space: $$ E(X) = \int_\Omega X(\omega)d\omega = \sum_i \int_{E_i} X(\omega) d\omega = \sum_i E(X;E_i) = \sum_i E(X\mid E_i) P(E_i).$$ If we're already conditioning on something, the relationship we can write down is $$ \begin{align}E(X\mid E) &= \frac{1}{P(E)} E(X;E) \\&= \frac{1}{P(E)}\int_E X(\omega) d\omega \\&= \frac{1}{P(E)} \sum_i E(X;E\cap E_i)\\&=\frac{1}{P(E)} \sum_i E(X\mid E\cap E_i)P(E\cap E_i)\end{align}.$$
So the thing you want to integrate against is not $f_Y(y)$ (analogous to $P(E_i)$) but rather something analogous to $P( (X>Y)\cap (Y=y)).$ Or, rather, since we can bring the $\frac{1}{P(E)}$ inside the sum and write $$ E(X\mid E) = \sum_i E(X\mid E\cap E_i)P(E_i\mid E),$$ we want to integrate against the conditional $P(Y=y\mid X>Y),$ which if we permit ourselves some more informal manipulations, is given by
$$P(Y=y\mid X>Y)= \frac{P(X>y\mid Y=y)P(Y=y)}{P(X>Y)} = \frac{\frac{1}{2}(2-y)\frac{1}{2}}{\frac{1}{2}} = 1-\frac{y}{2}.$$
So, your $$ \int_0^2 \left(1-\frac{y}{2}\right)\frac{1}{2}dy= \frac{1}{2}$$ becomes $$ \int_0^2\left(1-\frac{y}{2}\right)^2dy=\frac{2}{3}.$$