Ruby/String/upcase

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

Содержание

Call upcase function from string class on a sentence

puts "This is a test".upcase



Call upcase function from string on a word

"Test".upcase



Change string to upper case in place

string = "My first string"                   # => "My first string"
string.upcase!                           # => "MY FIRST STRING"



upcase does not change the original string

un_banged = "Hello world."
un_banged.upcase    # => "HELLO WORLD."
un_banged       # => "Hello world."
banged = "Hello world."
banged.upcase!      # => "HELLO WORLD."
banged          # => "HELLO WORLD."



upcase or upcase!

puts "warning! hot!".upcase