0
這使我瘋狂了很久,我使用SIMPLE字符串替換,但它無法替換字符串(在這種情況下,它是'url' )根據它獲得的信息。Ruby'sub!'如果/ elsif語句不會替換文本
class Test
myURL = 'www.google.com'
puts 'Where are you from?'
location = gets
if location == 'England'
myURL['.com'] = '.co.uk'
elsif location == 'France'
myURL['.com'] = '.co.fr'
end
puts myURL
end
我會瘋了嗎?
你不在代碼中使用'sub!'。 – 2013-03-25 03:38:34