Skip to end of metadata
Go to start of metadata

Functions do not necessarily have to be created inside of classes in Boo.

This is valid code:

So is this:

Functions can also be placed inside other functions (these are called Closures or "blocks" in some languages).

Closures are also handy in a variety of other situations.

There are also 3 special functions that can be used in classes. They are constructor, static constructor, and destructor. Each have no return type, modifiers, or attributes. Only the plain constructor takes parameters. Constructors are invoked when an instance is created. Static constructors are called only the first time the type is used. They should be used to initialize uninitialized static fields. Destructors perform commands when objects are freed.

See also:

Parameters, Callable Types, Events
Closures in Boo
Martin Fowler yammering about Closures

  • No labels

2 Comments

  1. Some documentation on how to do extension methods would be awesome. Maybe this will work as a start?

    Extension methods

    To create an extension method, simply add the Extension attribute to a static method. The first argument's type is the type being extended.

  2. In the current version (0.9.4) it seems that extension methods don't need the static keyword anymore.