You can define a convention for a project and without providing any code to a remote colleague
implement a compatible solution with him. This can be of great benefit in the web development
environment where it is usual that many libraries are supposed to work together to outfit the final
product.
The same applies not only to objects but to any type definition. It is interesting for example having a
function that accepts another function as an argument; the argument can be an inline function, an object
method, or a class static function. Here ??™ s an example:
class StringDecoration
{
var prefix : String;
public function new(prefix : String)
{
this.prefix = prefix;
}
public function decorate(s : String)
{
return prefix + s;
}
}
class Main
131
Chapter 5: Delving Into Object-Oriented Programming
{
public static function print(s : String, decorate : String - > String)
{
var o = decorate(s);
trace(o);
}
public static function quote(s : String)
{
return ????????™ + s + ????????™;
}
public static function main()
{
var decorator = new StringDecoration(???- > ???);
var s = ???John???;
print(s, quote); // traces ???John???
print(s, decorator.
Pages:
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275