1
的陣列循環我有以下的CoffeeScript:CoffeeScript的類 - 通過繼承的對象
class Vehicles
constructor: (@name) ->
class Car extends Vehicles
setId: (@id) ->
setName: (@name) ->
class Truck extends Vehicles
setId: (@id) ->
setName: (@name) ->
m3 = new Car
m3.setId 2
m3.setName 'BMW M3'
m5 = new Car
m5.setId 4
m5.setName 'BMW M5'
「汽車」對象將動態地從數據陣列而產生。
在Vehicles類中,我將如何遍歷所有Car對象並訪問每個單獨的屬性?
謝謝!
真棒!謝謝 :) – dzm 2012-03-26 17:22:19