Do I need to construct a function $g$? Royden, Real Analysis, 2.6. item 40. problem:

I am letting $g(x) =
\begin{cases}
f(x),  & \text{if $x\in F$} \\[2ex]
\frac{f(a)-f(b)}{a-b}(x)+\gamma, & \text{if $x\notin F$}
\end{cases}$
and let $\gamma\in\Bbb{R}$ be the "y-intercept"(I'm thinking how to write this formally) and let $b$ be the least upperbound of all elements less than or equal to $a$ in $\Bbb{R}$.
However the solution manual provided

Question: Why do I need to mention $F$ is closed and $F^c$ is open and they're the union of a countable collection of open intervals? Also, the manual only mentioned to take $g$ to be linear, but, for me, I think the author of the solutions was simply not trying to be careful since the exercise is a bit trivial?
 A: For some, the hint given with the problem statement counts already a full solution, for others, the solution in the solution manual is only an extended informal hint. I suppose you want to make the definition of $g$ sufficiently formal. I think this could be done (note that the definition of $g$ does not yet comprise the proof of the desired properties of $g$):
For $x\in\Bbb R$ let $u(x)=\inf(F\cap [x,\infty))$ and $v(x)=\sup(F\cap(-\infty,x])$. Note that 


*

*$u(x)\in F\cup\{+\infty\}$ and $v(x)\in F\cup\{-\infty\}$

*at least one of $u(x),v(x)$ is finite unless $F=\emptyset$

*$v(x)<x<u(x)$ for $x\notin F$ (because $F$ is closed!)

*$u(y)=u(x)$, $v(y)=v(x)$ for $y$ with $v(x)<y<u(x)$, i.e.,  $u,v$ are constant in a neighbourhood of $x$ for $x\notin F$


For $x_1,x_2,y_1,y_2\in\Bbb R$ with $x_1<x_2$ let 
$$h_{x_1,x_2,y_1,y_2}(x)=\frac{y_2(x-x_1)+y_1(x_2-x)}{x_2-x_1}.$$
Then $h_{x_1,x_2,y_1,y_2}$ is a continuos function $\Bbb R\to\Bbb R$ with $h_{x_1,x_2,y_1,y_2}(x_1)=y_1$ and $h_{x_1,x_2,y_1,y_2}(x_2)=y_2$. Now let
$$ g(x)=\begin{cases}f(x)&x\in F\\
h_{v(x),u(x),f(v(x)),f(u(x))}(x)&x\notin F, -\infty<v(x)<u(x)<\infty\\
f(u(x))&x\notin F, v(x)=-\infty,u(x)<\infty\\
f(v(x))&x\notin F, u(x)=\infty,v(x)>-\infty\\
42&F=\emptyset
\end{cases}$$
