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

  • SEARCH
  • Home
  • 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 8698363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:42:59+00:00 2026-06-13T01:42:59+00:00

Hello my problem is simple I have code which simplified looks like this foo

  • 0

Hello my problem is simple I have code which simplified looks like this

foo = OpenStruct.new
bar = OpenStruct.new

mappings.each do |k,v|
 eval "foo.#{k} = bar.#{v}"
end

I am trying to fix this eval use and not use it 🙂 Figured out the right part but I do not know how to assign to left one. To access getter you could write.

 bar.send(v.to_sym)
 # not to sure how to access setter for foo

I am using Ruby 1.8.7, Thank you

  • 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-13T01:43:00+00:00Added an answer on June 13, 2026 at 1:43 am

    Not sure about 1.8.7, but in newer Rubies this works:

    foo.send("#{k}=".to_sym, bar.send(v.to_sym))
    

    Also, in newer versions, send accepts strings as well, so you can omit .to_sym.

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

Sidebar

Related Questions

Problem Hello all! I have this code which takes my jpg image loops through
I just installed node.js on Windows. I have this simple code which does not
Hello folkes I have this little problem for which I cannot find a suitable
I've got a problem which makes me crazy because it looks like a simple
Hello everyone my problem is very simple. Using entity framework code first I want
I have a batch file which starts multiple instances of simple console application (Hello
Hello all i have a simple problem i have a alertDialog and i want
So I have a a text file that looks something like this: public >ret
I have the following code, which implements a simple C++ class (ObjWithPyCallback) with a
So this is a simple javascript code which turns money in the digits into

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.