Let $-\infty\leq a<b\leq \infty$. Prove that a function $f$ is uniformly continuous on the interval $(a,b)$ if and only if it has a uniformly continuous extension to all of $\mathbb{R}$.
Definition: A function $f: D \longrightarrow \mathbb{R}$ is uniformly continuous on $D$ if for every $\epsilon > 0$ there exists some $\delta > 0$ such that $|f(x) - f(y)| < \epsilon$ whenever $|x-y|<\delta$.
My attempt:
($\longrightarrow$) Suppose $f$ has a uniformly continuous extension to all of $\mathbb{R}$. In other words, there exists a uniformly continuous function $g:\mathbb{R}\longrightarrow \mathbb{R}$ such that $g(x) = f(x)$ for all $x\in(a,b)$. But since $g$ is uniformly continuous on all of $\mathbb{R}$, then of course it is uniformly continuous on $(a,b)$, which means $f$ is uniformly continuous on $(a,b)$.
Does that work? and how would you show the other direction?