“Строка формат Ruby” Ответ

Строка формат Ruby

name1 = "John"
name2 = "Mary"
"hello, #{name1}.  Where is #{name2}?"
Anas Mahasin Nabih

Рубиновой струнный формат

time    = 5
message = "Processing of the data has finished in %d seconds" % [time]
puts message
Output => "Processing of the data has finished in 5 seconds"

score = 78.5431
puts "The average is %0.2f" % [score]
Output => The average is 78.54

puts "122 in HEX is %x" % [122]
Output => 122 in HEX is 7a

puts "The number is %04d" % [20]
Output => The number is 0020

names_with_ages = [["john", 20], ["peter", 30], ["david", 40], ["angel", 24]]
names_with_ages.each { |name, age| puts name.ljust(10) + age.to_s }
# Prints the following table
john      20
david     30
peter     40
angel     24
Zagham Abbas

Ответы похожие на “Строка формат Ruby”

Вопросы похожие на “Строка формат Ruby”

Смотреть популярные ответы по языку

Смотреть другие языки программирования