help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Function names, same as return value ?


From: siko1056
Subject: Re: Function names, same as return value ?
Date: Sun, 20 Dec 2015 11:39:36 -0800 (PST)

Hello Ted,

It is possible, but I would not recommend it. Here is one example, where it
is not possible to do:

function [fib] = fib (n)
  fib = 1;
  if n > 1
    fib = n * fib (n - 1);
  endif
endfunction

>> fib (4)
error: fib: A(I): index out of bounds; value 3 out of bound 1
error: called from
    fib at line 4 column 9

So consider for you code, if a confusion between (like above) a variable
name and a recursive function call can happen.

HTH, Kai



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Function-names-same-as-return-value-tp4674117p4674135.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]