Funzione Ruby per rimuovere tutti gli spazi bianchi?

Qual è la funzione Ruby per rimuovere tutti gli spazi bianchi? Un po' come la funzione trim() di php?

s = "I have white space".delete(' ')

E per emulare la funzione trim() di PHP:

s = "   I have leading and trailing white space   ".strip
Commentari (12)

Risposta correlata:

"   clean up my edges    ".strip

restituisce

"clean up my edges"
Commentari (4)

Inoltre, non dimenticare:

$ s = "   I have white space   ".split
=> ["I", "have", "white", "space"]
Commentari (2)