Re: LIST "bug": .Remove on an empty list [message #73992 is a reply to message #73991] |
Tue, 14 December 2010 07:49   |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
On Dec 14, 1:35 pm, Paul van Delst <paul.vande...@noaa.gov> wrote:
> If there
> was a list "Empty" or "IsEmpty" method (like ruby's "empty?" method...for both arrays/lists and hashes), I would be more
> tempted to use it,
>
> if ( l.isempty() ) then ...return, handle error, whatever...
>
> as opposed to the current IDL idiom,
>
> if ( n_elements(l) eq 0 ) then ...return, handle error, whatever...
>
> For some reason I find this type of mixture of functional and object coding jarring - and this is from someone who has
> spent most of his life writing Fortran code! (I think it's also why ruby appeals to me more than python).
I agree there should be an empty() method. Besides the reason you
mentioned, it is also more direct and expressive to just test for
empty() than to do a comparison with a function call. I will add that
to the class I am writing to support assignment in arrays inside
lists.
|
|
|