octave-maintainers
[Top][All Lists]
Advanced

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

Re: help needed to understand handles to classdef methods


From: khalil2535
Subject: Re: help needed to understand handles to classdef methods
Date: Mon, 25 Feb 2019 15:07:06 -0600 (CST)

Hope you got things as expected , that's matlab r2018a


=== code begin ===


>> x = method_handle ()

x = 

  method_handle with no properties.

>> x.bar (1)

ans =

    'method_handle.foo: 1'

>> x.bar (2)

ans =

    'method_handle.foo: 2'

>> x.bar (3)

ans =

    'method_handle.foo: 3'

>> [h1, h2, h3] = x.get_handles ()

h1 =

  function_handle with value:

    @foo


h2 =

  function_handle with value:

    @(self,n)self.foo(n)


h3 =

  function_handle with value:

    @(~,n)self.foo(n)

>> h1 (x, 1)

ans =

    'method_handle.foo: 1'

>> h2 (x, 2)

ans =

    'method_handle.foo: 2'

>> h3 (x, 3)

ans =

    'method_handle.foo: 3'

>> x.h1 (1)
Undefined function 'foo' for input arguments of type 'double'.
 
>> x.h2 (2)
Not enough input arguments.

Error in method_handle>@(self,n)self.foo(n) (line 17)
      self.h2 = @(self, n) self.foo (n);
 
>> x.h3 (3) 
Not enough input arguments.

Error in method_handle>@(~,n)self.foo(n) (line 18)
      self.h3 = @(~, n) self.foo (n);

=== code end ===



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-Maintainers-f1638794.html



reply via email to

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