我不明白为什么这种方法不起作用。当我输入一个应该通过 if 语句的值时,它不起作用。
def getBase
puts "What is the base URL for the test?"
x = gets
if (x.include? 'http://') && ((x.split('.').at(x.split('.').length - 1).length) == 3)
return x
else
puts "That is in the incorrect format."
puts "Please format your url like this"
puts "http://example.com"
getBase
end
end
输入' http://test.com '
结果:语句重复并且不退出递归