Skip to content
Nathan Jeffords edited this page Dec 15, 2013 · 4 revisions

Added by Jeffery Olson

part of the Boo Language Guide

Using .NET Generics in Boo

The general syntax for generics in boo is id [ of ... ] where id is the generic entity being declared or referenced and ... is the list of generic parameters or arguments. In the case of declarations, a parameter can be given a list of constraints by following its identifier with a parenthesized list of constraints. For example, entity [ of type (class)] declares that entity is a generic taking a single parameter 'type' that must be a class type.

Declaring references to generic types

  • include foo* for IEnumerable

Generic Method Invocation

To specify generic arguments to a method invocation, use square brackets with the of keyword as in the following example where instance is an instance of some class with a generic method named Method taking a single generic type argument named Type and a single normal argument named argument.

instance.Method [of Type] (argument)

Defining Generic Types

Generic Classes

  • Generic classes
  • Generic methods

Generic Constraints

Clone this wiki locally