common_string_methods
🔠Common String Methods​
Ruby provides many handy methods like upcase
, downcase
, capitalize
, and reverse
. These return new strings and do not change the original unless you use the bang version (e.g., upcase!
).
s = "ruby"
puts s.upcase # => "RUBY"
puts s.capitalize # => "Ruby"
puts "Madam".reverse # => "madaM"