【发布时间】:2016-05-01 07:30:21
【问题描述】:
我一直在网上搜索。有很多资源可以解释以下代码中更大的概念,但没有解释较小细节的用途和/或含义。前两行是什么意思? (另外,我是初学者。)
word = 'word'
words =[]
puts 'Please type as many words per line then press the Enter Key.'
puts 'When you are finished press the Enter Key without typing anything.'
while word != ''
word = gets.chomp
words = words.push word
end
puts ''
puts 'Your original values:'
puts words
puts ''
puts 'Your values sorted:'
puts words.sort
puts ''
【问题讨论】:
-
word = 'word'和words = []分别为word和words初始化默认值
标签: ruby variables object variable-assignment