0
target.size
在下面的代碼中表示什麼?w
是什麼意思是文件名稱旁邊的?當我刪除w
或.size
這個程序是什麼意思?什麼是.size是什麼意思
filename = ARGV.first
script = $0
puts "We're going to erase #{filename}."
puts "If you don't wnat that, hit CTRL-C (^C)."
puts "If you do want that, hit RETURN."
print "? "
STDIN.gets
puts "Opening the file..."
target = File.open(filename,'w')
puts "Truncating the file. Goodbye!"
target.truncate(target.size)
puts "Now I'm going to ask you for three lines."
print "line 1: "; line1 = STDIN.gets.chomp()
print "line 2: "; line2 = STDIN.gets.chomp()
print "line 3: "; line3 = STDIN.gets.chomp()
puts "I'm going to write these to the file"
target.write(line1)
target.write("\n")
target.write(line2)
target.write("\n")
target.write(line3)
target.write("\n")
puts "And finally, we Close it"
target.close()
抱歉,但我不明白我是專業的紅寶石對不起 你可以把它簡單 –
@AhmedTaker你有什麼更多的困惑,告訴我.. –
瓦特=可寫 但到底是什麼意思規模,爲什麼做代碼沒有崩潰時,我刪除.size –