Science, Tech, Math › Computer Science Array as a Function Return Type and Method Parameter Share Flipboard Email Print Getty Images/Kristin Lee Computer Science Delphi Programming Delphi Tutorials Advanced PHP Programming Perl Python Java Programming Javascript Programming C & C++ Programming Ruby Programming Visual Basic View More By Zarko Gajic Zarko Gajic Twitter Computer Science Expert MSCS, Computer Science, University of Osijek Zarko Gajic is experienced in SQL and has working knowledge of DB systems such as MS SQL Server, Firebird, Interbase, and Oracle. He is also proficient in XML, DHTML, and JavaScript. Learn about our Editorial Process Updated on February 13, 2019 Arrays in Delphi allow us to refer to a series of variables by the same name and to use a number (an index) to tell them apart. Here's an example integer array that can hold up to 7 (integer) values. Note: this is a fixed-size static Delphi array declaration. Arrays as Function Return Types In Delphi, functions are routines that return a value. When you want a function to return an array type variable, you might be tempted to use the next declaration: When you try to compile this code, you'll get the next compile-time error: [Pascal Error] E2029 Identifier expected but 'ARRAY' found. Obviously, when you declare functions that will return array value, you cannot include index type specifiers return declaration. In order to allow a function to return an array value, you first need to create a custom array type, then use it as a return function type: Arrays as Method/Routine Properties Similar to using arrays as function return types, when you declare routines that take array parameters, you cannot include index type specifiers in the parameter declarations. Cite this Article Format mla apa chicago Your Citation Gajic, Zarko. "Array as a Function Return Type and Method Parameter." ThoughtCo, Aug. 27, 2020, thoughtco.com/array-as-a-function-return-type-1057837. Gajic, Zarko. (2020, August 27). Array as a Function Return Type and Method Parameter. Retrieved from https://www.thoughtco.com/array-as-a-function-return-type-1057837 Gajic, Zarko. "Array as a Function Return Type and Method Parameter." ThoughtCo. https://www.thoughtco.com/array-as-a-function-return-type-1057837 (accessed May 31, 2023). copy citation Featured Video