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 6121139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:45:00+00:00 2026-05-23T15:45:00+00:00

How can I do this in Ruby?: Sometimes for diagnostics in interpreted language, it’s

  • 0

How can I do this in Ruby?:

Sometimes for diagnostics in interpreted language, it’s faster for me to make a quick alteration to my code, tossing an object into the top-level namespace, then mess with it there in an interactive environment.

In Python, I add this to my code:

import __main__
__main__.[field] = [my problematic object]

…then run the file with a command python -i [myfilename]. Any idea how I can get access to the top-level namespace in Ruby?

  • 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-05-23T15:45:01+00:00Added an answer on May 23, 2026 at 3:45 pm

    I’d recommend using Pry for this.

    Run gem install pry to install pry. Then add the following code where you want to start an interactive session.

    require 'pry'
    binding.pry
    

    An example of an interactive session.

    $ cat debug.rb
    a = 7
    b = 6
    product = a * b
    require 'pry'
    binding.pry
    puts "The answer is: #{product}"
    
    $ ruby debug.rb
    
    From: debug.rb @ line 5 in Object#N/A:
    
         1: a = 7
         2: b = 6
         3: product = a * b
         4: require 'pry'
     =>  5: binding.pry
         6: puts "The answer is: #{product}"
    pry(main)> product
    => 42
    pry(main)> product = -1 * a * b
    => -42
    pry(main)> exit
    The answer is: -42
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a Ruby design problem. How can I make a reusable flat file
How can I implement this in Ruby? Is there any one line of code
is there any way I can reproduce this ruby function: def Password.hash(password,salt) Digest::SHA512.hexdigest(#{password}:#{salt}) end
How can this line in Java be translated to Ruby: String className = java.util.Vector;
How can I do this on Ruby? puts some_method(ò) # => ò In other
How can I do the Ruby method Flatten Ruby Method in C#. This method
I can't seem to compile ironruby in ruby 1.8.7. I always get this error:
On windows, I can run my ruby script like this: > ruby myscript.rb but
I'm not sure this is possible, but in ruby, you can dynamically call a
I'm failing at translating the following PHP/ImageMagick code into Ruby RMagick (to make 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.