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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:02:33+00:00 2026-05-20T05:02:33+00:00

Okay, per suggestions on clarifying the intent I have restated the question. Hope this

  • 0

Okay, per suggestions on clarifying the intent I have restated the question. Hope this example is clear.

$funcname = ""
$message = ""
$DebugFormat = "Within #{$funcname} message: #{$message}"


def Something
   $funcname = "Something"
   # .
   # .
   # .
   $message = "an important message."
   puts "#{$DebugFormat}"

end

def Another
   $funcname = "Another"
   # Another method related code ...
   $message = "Result message to output"
   puts "#{$DebugFormat}"
end

So, the idea is to have various debug related strings to use in various places without needing to repeat the same formatting and such.

Anyway, this isn’t super critical it’s more just an attempt to try and learn Ruby better.

go easy,

-daniel

  • 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-20T05:02:34+00:00Added an answer on May 20, 2026 at 5:02 am

    No, this is not possible as you have shown. the #{} syntax is just for string interpolation, so when you write PP = "[#{fname}]", it’s simply storing the string [Empty] in the variable PP. Strings have no memory of what code was used to produce them.

    It’s unclear what you’re attempting to achieve with this, but more than likely a method would be more appropriate than string interpolation.


    Update since your edit: It seems you want to create a sort of simulated stack trace. String interpolation still doesn’t make sense. Instead, you could do something like this:

    def debug(message)
      puts "#{ caller[0][/`([^']*)'/, 1]}: #{message}"
    end
    
    def something
      debug "an important message"
    end
    
    def another
      debug "result message to output"
    end
    
    something
    another
    

    Based on your strange usage of global variables and constants, it seems you’re trying to apply ideas from some other language in ways that don’t fit with Ruby. I’d recommend looking through a Ruby book to get familiar with the basics.

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

Sidebar

Related Questions

Okay this question is very simple: I have a facebook page, and a website.
I hope I can word this okay. I have multiple divs all called '.collapse-conten'
Okay, next PHPExcel question. I have an HTML form that users fill out and
Okay, this is probably a very basic question; but, I'm just getting back in
Okay, so I have this page, which has one Ajax:AsyncFileUploader also some other ajax
Okay, I implemented this SO question to my code: Return True or False Randomly
Still no answer...anyone have something better? Okay complex 2 part question here. I have
Okay, I feel a bit foolish for having to ask this but I guess
Okay, I have the following create action #posts_controller, nested resource under discussions def create
Okay, so I have my post.php page. If you are not logged in, you'll

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.