Logo

Programming-Idioms

History of Idiom 219 > diff from v39 to v40

Edit summary for version 40 by programming-idioms.org:
[Ruby] +DemoURL

Version 39

2021-12-23, 09:06:17

Version 40

2021-12-23, 10:47:40

Idiom #219 Replace multiple spaces with single space

Create string t from the value of string s with each sequence of spaces replaced by a single space.

Explain if only the space characters will be replaced, or the other whitespaces as well: tabs, newlines.

Idiom #219 Replace multiple spaces with single space

Create string t from the value of string s with each sequence of spaces replaced by a single space.

Explain if only the space characters will be replaced, or the other whitespaces as well: tabs, newlines.

Extra Keywords
collapse repeated
Extra Keywords
collapse repeated
Code
t = s.squeeze(" ")
Code
t = s.squeeze(" ")
Comments bubble
Just spaces.
Comments bubble
Just spaces.
Demo URL
https://replit.com/@ProgIdioms/StaleCuteLicensing#main.rb