# Declaration commands of setspace have no effect inside groups

According to this answer of the question change space to only a part of the document (about 8 years ago), the effect of setspace' declaration commands (\singlespacing, \onehalfspacing, \doublespacing) should be limited by groups.

But the following MCE shows that:

• outside groups, these commands have the expected effect.
• inside groups, these commands have... no effect!

Do you know why?

\documentclass{article}
\usepackage{setspace,lipsum,xcolor}
% Paragraphs in red:              in single spacing.
% Paragraphs in blue: (should be) in double spacing.
\begin{document}
\footnotesize % In order to get a single page.

% Single spacing is the default.
\color{red}
\lipsum[1]

% \doublespacing outside a group switches to double spacing.
\doublespacing
\color{blue}
\lipsum[1]

% Back to default: \singlespacing outside a group switches to single spacing.
\singlespacing
\color{red}
\lipsum[1]

% \doublespacing inside a group DOESN'T switch to double spacing.
{% %% <<<<<<< begin a group
\doublespacing
\color{blue}
\lipsum[1]
} %% <<<<<<< end a group

% \doublespacing inside a group DOESN'T switch to double spacing.
\bgroup %% <<<<<<< begin a group
\doublespacing
\color{blue}
\lipsum[1]
\egroup %% <<<<<<< end a group
\end{document}


A paragraph is set using the setting at the end of a paragraph so leave a blank line before the closing } otherwise the settings are lost before the paragraph ends.
This is most commonly seen with size commands like \large where the font change happens at the point of the declaration but the associated change of baselineskip only happens if the paragraph ends in the same scope.