help-octave
[Top][All Lists]
Advanced

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

Re: cs-lists and multiple return arguments


From: Jordi Gutiérrez Hermoso
Subject: Re: cs-lists and multiple return arguments
Date: Sun, 30 Oct 2011 08:44:34 -0600

2011/10/28 Jordi Gutiérrez Hermoso <address@hidden>:
> On 28 October 2011 11:45, Przemek Klosowski <address@hidden> wrote:
>> On 10/28/2011 02:26 PM, Jordi Gutiérrez Hermoso wrote:
>>>
>>> I don't understand why this works:
>>>
>>>     [a,b] = {1, 2}{:}
>>>
>>> but this doesn't
>>>
>>>     [a,b] = 1,2
>>
>> 1,2 is two statements; statement '2' doesn't do much while '1' tries to
>> supply both results ('a' and 'b'), and fails.
>>
>> [a,b] = deal(1,2) works fine---that's what 'deal()' was intended for.
>
> Yeah, I know, but in every other situation I can think of, a cs-list
> is syntactically identical to typing out its elements one by one. Why
> doesn't that work here? Also, a common use of deal is like this:
>
>    [a b] = deal(c{:})
>
> but
>
>    [a b] = c{:}
>
> makes this completely superfluous. I am curious to know if [a, b] =
> c{:} works in Matlab.

Seems like it also works in Matlab. I'm thoroughly confused as to why
this works. I guess I'll just live with it working and start using
this trick.

- Jordi G. H.


reply via email to

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