I'm struggling to understand the absolute value.
By definition we have \begin{align*} |x| = \begin{cases} -x & \text{if} \ \ x < 0,\\[2 mm] x & \text{if} \ \ x \geq 0 \end{cases} \end{align*}
Then my book says:
Example 1: $f(x)=|x-2|$, determine the domain, codomain and draw the graph. \begin{align*} f(x) = \begin{cases} x - 2, & \text{if} \ \ x-2 < 0\\[2 mm] -(x - 2),& \text{if} \ \ x-2 ≥ 0 \end{cases} \end{align*}
I just want to know how is this related to the first definition.
How is $x - 2$ less than $0$? and why they put $-(x-2)$? And how is that $x - 2\geq 0$?
I've been trying to understand that and inequations or inequalities with absolute value, but nothing comes to my mind.
Thank you.
Note: I'm sorry in $f(x)$ I first wrote "$-x+2$, if $x-2≥0$", but the book said "$-(x-2)$". Still don't understand at all.