Let $\mathbb R \supseteq D := (-\infty,-1) \cup \{0\} \cup (1, +\infty)$. We define a function $f: D \to \mathbb R$ by $$f(x) = \begin{cases} x+1 &\text{if} \quad x \in (-\infty,-1) \\ x-1 &\text{if} \quad x \in (1, +\infty) \\ 0 &\text{if} \quad x =0 \end{cases}$$
I would like to prove that $f$ is continuous on $D$. Clearly, $f$ is continuous on $D - \{0\}$, so it suffices to prove that $f$ is continuous at $0$.
Clearly, $f(0) = 0$. Let $U$ be an arbitrary neighborhood of $0$ in $\mathbb R$. Let $U'= (-1,1) \cap D =$ $\{0\}$. Then $U'$ is a neighborhood of $0$ in $D$. We have $f[U'] = \{0\} \subseteq U$. As such, $f$ is continuous at $x=0$.
My questions:
Because $0$ is not a limit point of $D$, $\lim_{x \to 0} f(x)$ is not defined. As such, I can not appeal to the notion limit of a function at point $x=0$. Hence I must use the more general definition of continuity in the metric space. Is my understanding correct?
Could you please verify if my proof looks fine or contains logical gaps/errors? Any suggestion is greatly appreciated.
Thank you so much!