Этот пример - то, что я пытался сделать, но ColdFusion говорит, что `подпрограммы могут быть объявлены только один раз.Может ли ColdFusion сделать что-то подобное?
/**
* @hint Handles vehicles
*/
component Vehicle
{
this.stock = "";
this.year = "";
this.make = "";
this.model = "";
public Vehicle function init()
{
return this;
}
public Vehicle function init(string stock)
{
this.stock = stock;
//Get the year, make model of the stock number of this vehicle
return this;
}
public string function getYearMakeModel()
{
var yearMakeModel = this.year & " " & this.make & this.model;
return yearMakeModel;
}
}
Как ни странно, если я уберу первый init()
, я могу использовать либо new Vehicle()
, либо new Vehicle(stocknumber)
, и в любом случае он вызывает init(string stocknumber)
, но это не то поведение, которое мне нужно...