12.07.2015 Views

ILOG OPL Development Studio Language Reference Manual

ILOG OPL Development Studio Language Reference Manual

ILOG OPL Development Studio Language Reference Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Defining methodsSince a method is really a property which contains a function value, defining a method simplyconsists in defining a regular function, then assigning it to a property.For example, the following program adds a method start to the myCar object defined inthe previous section:function start_engine() {writeln("vroom vroom")}myCar.start = start_engineNow, the expression myCar.start() will call the function defined as start_engine.Note that the only reason for using a different name for the function and for the method is toavoid confusion; we could have written:function start() {writeln("vroom vroom")}myCar.start = startI L O G O P L D E V E L O P M E N T S T U D I O L A N G U A G ER E F E R E N C E M A N U A L245

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!