Re: [Rd] Surprising behavior when using the reference class with the dollar symbol

2021-03-27 Thread Jiefei Wang
Thank you for the clarification! Wow, I do not know the same rule applies to the list object. Maybe that's because the list object will give NULL not an error. I might have incorrectly used it in my package. Best, Jiefei On Sun, Mar 28, 2021 at 3:26 AM Bill Dunlap wrote: > > > > It looks like wh

Re: [Rd] Surprising behavior when using the reference class with the dollar symbol

2021-03-27 Thread Bill Dunlap
> > It looks like when calling the dollar symbol using the function format, it > > treats the input argument as a character literal and does not evaluate it > > inside the function. I know we have the function `field` to get the slot > > variable, but I wonder if this is designed on purpose as the

Re: [Rd] Surprising behavior when using the reference class with the dollar symbol

2021-03-27 Thread Jiefei Wang
Thanks, Duncan. Below is the repost of my question in plain text mode. I'm trying to get the field value of a reference object by the field name, but the dollar symbol behaves quite unusual. See example below .foo <- setRefClass( "foo", fields = list( a = "integer" ) ) x <- .

Re: [Rd] Surprising behavior when using the reference class with the dollar symbol

2021-03-27 Thread Duncan Murdoch
On 27/03/2021 10:16 a.m., Jiefei Wang wrote: Hi all, I'm trying to get the field value of a reference object by the field name, but the dollar symbol behaves quite unusual. See example below *.foo <- setRefClass("foo",fields = list(a = "integer" ))x <- .foo$new(a=1L

[Rd] Surprising behavior when using the reference class with the dollar symbol

2021-03-27 Thread Jiefei Wang
Hi all, I'm trying to get the field value of a reference object by the field name, but the dollar symbol behaves quite unusual. See example below *.foo <- setRefClass("foo",fields = list(a = "integer" ))x <- .foo$new(a=1L)## This is OKx$a## This is OK`$`(x, "a")## But