Can function return more than one value?

1 answer

Answer

1095902

2026-04-30 02:46

+ Follow


Strictly speaking, only one.

However, a trick many programmers use is to have the function create "side effects" by changing the value of its arguments as well as returning a value. A pseudocode example might be something like a file-existence checker. It would be a boolean function that returns TRUE if the file exists and FALSE if it doesn't. However, depending on the language used it could also modify its arguments so they provided the file's size and record type if it exists. For example: if bFileExists (cFileName, iFileSize, iRecType) then {do something with iFileSize ...}


ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.