Methods with Variable Number of Parameters

    The print method of the class

class MyScreen
  public:
    proc print( v : ... array(Any)[] )
      var i : integer;
      begin
      for i = 1 to v.getSize() - 1 do
        Out.write( v[i].toString() );
      end

    ...
end

accepts a variable number of parameters:

   myScreen.print( f, circle, person, 5, 'A' );

The parameters are packed in an array assigned to v.
 

What is new ?

    Not very much comparing with C++ or Java, although this feature in Green seems to be cleaner and easier to use than in those languages.

Return