我的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. wtf 我在这里做错了吗?