More about the Gosu type system
This topic further describes the Gosu type system and its advantages for programmers. Gosu is a statically typed language, rather than a dynamically typed language. In a statically typed language, all variables must be assigned a type at compile time. Gosu enforces this type constraint at compile time and at run time. If any code violates type constraints at compile time, Gosu flags this violation as a compile error. If your code violates type constraints at run time, for example, by making an invalid object type coercion, Gosu throws an exception.
Static typing in Gosu provides several benefits:
- Compile-time error prevention
- Intelligent code completion
Although Gosu is a statically typed language, Gosu supports a concept of generic types, called Gosu generics. You can use generics in special cases to define a class or method so that it works with multiple types of objects. Gosu generics are especially useful to design or use APIs that manipulate collections of objects. Programmers familiar with the Java implementation of generics quickly become comfortable with Gosu generics, although there are minor differences.
See also
