Programming Ruby 3.2 (5th Edition): B1.0 page 165, colon instead of point

@noelrappin

Page 165

This is a small detail, but usually you put a colon when a sentence announces an example, as for the second example :

The second form here is the rightward assignment we’ve already seen. This can be used in
more complex patterns:

[1, "potato", 2, "potato"] => [first, String, second, String]

There is a point instead of a colon for the second example

with that name.

and third example

This pattern assigns first but not second.

I was wondering if it was a previous pattern. In this case it would be particularly relevant to put a colon because This pattern announces the next example :

[1, "potato", 2, "potato"] in [Integer => first, Integer, Integer => second, String]

The usual pattern is it takes a colon if the sentence directly references the upcoming code, and a period otherwise. Admittedly, it’s not 100% consistent, but that’s the idea. (So,
the second example is fine, but the third one should have a colon).

Sometimes, there will be nothing there if the code is logically part of the previous sentence, but my editors tend to discourage that style these days, I think.

Thanks: