0
我得到一些奇怪的輸出,我的Ruby
代碼。下面是代碼:Ruby輸出不一致
mDate = schedule['date']
sTime = schedule['startTime']
eTime = schedule['endTime']
puts "Original Start Time: #{sTime}"
puts "Original End Time: #{eTime}"
puts "Original Date: #{mDate}"
sDate = mDate
eDate = mDate
puts "sDate: #{sDate}"
puts "eDate: #{eDate}"
@startTime = sDate.concat("T" + sTime + "Z")
@endTime = eDate.concat("T#{eTime}Z")
@date = schedule['date']
puts "Start Time: #{@startTime}"
puts "End Time: #{@endTime}"
puts "Date: #{@date}"
puts "Original Start Time: #{sTime}"
puts "Original End Time: #{eTime}"
puts "Original Date: #{mDate}"
這裏是輸出:
Original Start Time: 15:00:00
Original End Time: 15:00:00
Original Date: 2012-12-05
sDate: 2012-12-05
eDate: 2012-12-05
Start Time: 2012-12-05T15:00:00ZT15:00:00Z
End Time: 2012-12-05T15:00:00ZT15:00:00Z
Date: 2012-12-05T15:00:00ZT15:00:00Z
Original Start Time: 15:00:00
Original End Time: 15:00:00
Original Date: 2012-12-05T15:00:00ZT15:00:00Z
任何人都可以闡明一些,爲什麼1.值改變2.爲什麼的concat是增加的值的兩倍3.跆拳道我在這裏做錯了嗎?
謝謝。這解決了它。 :) – BlackHatSamurai
或者當你不打算進行變異時,不要使用變異方法(比如'concat')。 –
@AndrewMarshall:有效。 「爲什麼價值觀在變化?」 「因爲你改變了他們!」 :d – Amadan