help-octave
[Top][All Lists]
Advanced

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

Returning handles to subfunctions


From: John W. Eaton
Subject: Returning handles to subfunctions
Date: Mon, 10 Mar 2008 21:31:12 -0400

On 10-Mar-2008, Michael Friedlander wrote:

| The first function in this file returns a handle to a subfunction:
| 
| % -- file addnum.m --
| function addfunc = addnum(a)
|    addfunc = @(b)adder(a,b);
| end
| function c = adder(a,b)
|    c = a + b;
| end
| % -- end file
| 
| In Matlab, the call
| 
|  >> y = addnum(1); y(1)
| ans =
|       2
| 
| works, but gives an error in Octave.  Is this expected behavior?

What version of Octave are you using?

Here is what I see in the current stable version of Octave (3.0.0):

  octave:1> f = addnum (10)
  f =

  @(b) adder (a, b)

  octave:2> f (3)
  ans =  13

Is that the behavior you expect?

I strongly encourage you to upgrade to Octave 3.0.0.

Also, if you do think you have found a bug, then please report it to
the address@hidden list, not the help list.

Thanks,

jwe


reply via email to

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