You are about to replace all strings with uppercase and lowercase letters

Asked 2 years ago, Updated 2 years ago, 42 views

You are about to replace all of the ruby strings with uppercase and lowercase characters.

I used str.upper() in Python I tried everything with upper, tupper, upperCase, and convertUpper, but it didn't work.

What method should Ruby use?

ruby string

2022-09-22 22:10

1 Answers

puts "heLLo James!".downcase    #=> "hello james!"
puts "hello James! I'm Demi".upcase     #=> HELLO JAMES! I'M DEMI
puts "hello James! I'm Demi".capitalize #=> Hello james! i'm demi

If you want to replace the new string in the object itself without being returned, you can add ! after it.

string = "hello James!"
string.downcase!
puts string   #=> "hello james!"


2022-09-22 22:10

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.