Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8346467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:01:25+00:00 2026-06-09T07:01:25+00:00

I decided to give Reference Classes another shot, but my first hello world is

  • 0

I decided to give Reference Classes another shot, but my first hello world is already giving me issues. What is going wrong here?

> memory <- setRefClass(
+   Class = "memory",
+   fields = list(state="vector"),
+   methods = list(
+     get = function() { return(state) },
+     set = function(x) { state <<- x }
+   )
+ )$new()

> memory$set(123)

> print(memory)
Reference class object of class "memory"
Field "state":
[1] 123

> memory$get()
[1] 123

> print(memory)
Reference class object of class "memory"
Field "state":
Error in methods::show(field(fi)) : 
  error in evaluating the argument 'object' in selecting a method for function 'show': Error in get(name, envir = .self) : 
  unused argument(s) (name, envir = .self)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:01:27+00:00Added an answer on June 9, 2026 at 7:01 am

    I’m not very experienced with Reference Classes but according to the help page (?ReferenceClasses), I think that you have to add a show method to your class to be able to print automaticaly your object.

    memory <- setRefClass(
              Class = "memory",
              fields = list(state="vector"),
              methods = list(
              get = function() { return(state) },
              set = function(x) { state <<- x },
              show = function() {methods::show(state)}
              )
              )$new()
    
    
    memory$set(123)
    print(memory)
    #[1] 123
    
    memory$get()
    #[1] 123
    
    
    print(memory)
    #[1] 123
    

    Hope this help

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've never really bothered with math programming, but today I've decided to give it
[I've decided to give IntelliJ another go (to replace Eclipse), since its Groovy support
I'm new to WPF programming and decided to give it a shot by trying
I've decided to give Dojo a shot instead of using JQuery for once, and
decided to give Python a try for the first time, so sorry if the
I decided to give CodeRush/Refactor a go (after a rial of Resharper) and one
I came accross PetaPoco and decided to give it a try Did anyone come
I am new to Silverlight and have decided to give it a go. I
I'm coming from a TortoiseSVN background and decided to give TortoiseHg a try. One
With all the hype around MVC (and rightly so) I've decided to give it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.