Why that (!) need finished the capitalize!.. when ı remember it,that is wrong



When you use the !, your variable is changed.

To see the difference between using and not using !, try this code:

# get some info from the user
print "What's your first name?"
first_name = gets.chomp

# print the info with no !
puts "Your name is #{first_name}"

# print the info with a !
puts "Your name is #{first_name}"

Capitalizing/ formatting with string methods( capitalize!)

ı learn that. thank you =)


OK so when you want to capitalize the string (words/phrases) then you don't need ( ! ).
For example:
Print "This is my string".capitalize

On the other hand, if you are printing a variable, you need ( ! ) for the content to be capitalized.
For example:

Correct me if i am wrong:) but i think this is how it works


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.