3.1.1 A method that takes an argument

We can define a method similar to say-hello, called say-greeting, that takes an argument:

define method say-greeting (greeting :: <object>);
  format-out("%s\n", greeting);
end;

The say-greeting method has one required parameter, named greeting. The type constraint of the required parameter indicates the type that the argument must be. The greeting parameter has the type constraint <object>, which is the most general class. All objects are of the type <object>, so using this class as the type constraint allows the argument to be any object. You can omit the type constraint of a required parameter; that omission has the same effect as specifying <object> as the type constraint.

We can call say-greeting on a string:

? say-greeting("hi, there");
hi, there

We can call say-greeting on an integer, although the integer does not give a particularly friendly greeting:

? define variable *my-number* :: <integer> = 7;
? say-greeting(*my-number*);
7