Created
November 24, 2021 11:42
-
-
Save isokcevic/ed265973945ecd0caad00d3414aaa04f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = "A B C D" | |
puts | |
puts "Different name modifications" | |
puts "original #{name}" | |
puts "sub #{name.sub(' ', '')}" | |
puts "gsub #{name.gsub(' ', '')}" | |
puts "delete #{name.delete(' ')}" | |
puts | |
puts "Different length calculations" | |
puts "original #{name.length}" | |
puts "minus one #{name.length - 1}" | |
puts "sub #{name.sub(' ', '').length}" | |
puts "gsub #{name.gsub(' ', '').length}" | |
puts "delete #{name.delete(' ').length}" | |
puts "minus count #{name.length - name.count(' ')}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment