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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:45:52+00:00 2026-05-26T18:45:52+00:00

Maybe it is a stupid question, but i’m new to ruby, and I googled

  • 0

Maybe it is a stupid question, but i’m new to ruby, and I googled it, found these:

proc=Proc.new {|x| deal_with(x)}
a_lambda = lambda {|a| puts a}

But I want this:

def forward_slash_to_back(string)
...
def back_slash_to_forward(string)
...
def add_back_slash_for_post(string)
...
...
case conversion_type
when /bf/i then proc=&back_slash_to_forward
when /fb/i then proc=&forward_slash_to_back
when /ad/i then proc=&add_back_slash_for_post
else proc=&add_back_slash_for_post
end

n_data=proc.call(c_data)

But it gives me an error. I don’t know how to do that in Ruby, anyone can help?
thanks a lot!

  • 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-26T18:45:52+00:00Added an answer on May 26, 2026 at 6:45 pm

    “Function pointers” are rarely used in Ruby. In this case, you would normally use a Symbol and #send instead:

    method = case conversion_type
      when /bf/i then :back_slash_to_forward
      when /fb/i then :forward_slash_to_back
      when /ad/i then :add_back_slash_for_post
      else :add_back_slash_for_post
    end
    
    n_data = send(method, c_data)
    

    If you really need a callable object (e.g. if you want to use an inline lambda/proc for a case in particular), you can use #method though:

    m = case conversion_type
      when /bf/i then method(:back_slash_to_forward)
      when /fb/i then method(:forward_slash_to_back)
      when /ad/i then ->(data){ do_something_with(data) }
      else Proc.new{ "Unknown conversion #{conversion_type}" }
    end
    
    n_data = m.call(c_data)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is maybe a stupid question, but since I am relatively new to UDP
I'am new to jquery and maybe this is a stupid question but I have
This question is for a web application. And maybe it's a stupid question but
This maybe a stupid question, but as I can not easily undo my change
Well, maybe it is a stupid question, but I cannot resolve this problem. In
maybe stupid question, but i dont know answer. What is difference between using GetModuleHandle
Maybe this is a very stupid question but... Why should I use tinytext and
Maybe is just a stupid question, but, I would appreciate having an explanation of
Maybe I'm asking a stupid question, but I can't understand this behavior: <?php $this->meeting->google_id
I know maybe this is a stupid question, But i suck at sql But

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.