help-octave
[Top][All Lists]
Advanced

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

Re: override display() for class


From: bpabbott
Subject: Re: override display() for class
Date: Mon, 13 Dec 2010 19:04:45 +0000 (GMT)

On Dec 13, 2010, at 01:54 PM, "John W. Eaton" <address@hidden> wrote:

On 13-Dec-2010, bpabbott wrote:

| I wrote a simple class with display() overloaded. Both Octave and
| Matlab return "ans" for inputname(1) if there is no RHS variable.

I see the following behavior:

octave:3> function f (x)
> inputname (1)
> end
octave:4> f (1+2)
ans =
octave:5> x = 1; f (x)
ans = x

so if an _expression_ is passed to F, inputname (1) returns an empty
string Looking at the definition of inputname, I don't see how it
ever returns "ans".

jwe
 
You'll need to overload display. Take a look at the attached example.

octave:10> foobar
ans = Hello World.
octave:11> f = foobar
f = Hello World.

... and Matlab

>> foobar
ans = Hello World.
>> f = foobar
f = Hello World.

Ben

Attachment: @foobar.zip
Description: Zip archive


reply via email to

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