I had an obscure bug that boiled down to this ``feature'' in R, 

Read 3921 items
> A = list(aa = 1)
> A
$aa
[1] 1

> if (A$a) print("a is there")
[1] "a is there"

The test appear to check is A$a is TRUE, but what happen is that it
auto-complete (silently), and expand to 'A$aa'. 

The problem was caused by the fact that I had also a element named 'a'
which was evaluated to NULL,  like

> A$a = NULL
> A
$aa
[1] 1

> if (A$a) print("a is there")
[1] "a is there"

since NULL elements are removed from the list, and that A$a auto-expand
to A$aa, my error appeared.

To me, this seems not a feature I want in order to have a robust
program. 

Is there any option to turn this ''feature'' off? 

Best,
H



-- 
 Håvard Rue
 Department of Mathematical Sciences
 Norwegian University of Science and Technology
 N-7491 Trondheim, Norway
 Voice: +47-7359-3533    URL  : http://www.math.ntnu.no/~hrue  
 Fax  : +47-7359-3524    Email: havard....@math.ntnu.no

 This message was created in a Microsoft-free computing environment.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to