Here's a fun comparison between STRIP, SQUEEZE, SQUISH with an example:
Consider a string:
name = " Rushi Patel "
STRIP:
name.strip Output: "Rushi Patel"
Removes the spaces from the START and END of a string
SQUEEZE:
SQUEEZE:
name.squeeze Output: " Rushi Patel "
Literally squeezes the string, i.e squishes down any INTERNAL repeating whitespace to a SINGLE space.
SQUISH:
name.squish Output: "Rushi Patel"
Squish does both strip and squeeze. It's not directly available in Ruby, but it's made available in Rails. It's very useful.
Written by,
Rushi Patel
Written by,
Rushi Patel