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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:23:36+00:00 2026-06-03T13:23:36+00:00

I like to comment out parts of my code while testing but in Ruby

  • 0

I like to comment out parts of my code while testing but in Ruby it’s not so easy as compared to other languages. I’m aware of the current Ruby ways to comment but wonder if an alternative is possible. The code here is obviously not working, and i guess many have reasons not to do so, but could it be done ?

def /*
  =begin
end
def */
  =end
end

/*testing*/
//testing

/*
testing
on multiple lines
*/

puts 'test'
  • 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-03T13:23:38+00:00Added an answer on June 3, 2026 at 1:23 pm

    You can comment out multiple lines by using =begin and =end, but they must be located at the beginning of the line.

    class TestClass
    
      def my_method
    
      end
    
    =begin
      def another_method
        # ...
      end
    =end
    
    end
    

    Beyond this, the answer is that it can’t be done. You cannot use C-style multiline comments in Ruby. It is not a case of technical limitations, the language doesn’t support this. Regardless of how you make this work, as soon as you do you are no longer writing Ruby. You’ll have produced a broken dialect of Ruby that only your interpreter understands.

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

Sidebar

Related Questions

a while ago i could comment any code in php with netbeans like this:
A keyboard shortcut to comment/uncomment out a piece of code is common in other
I would like to find all comment blocks(/*...*/) but the function g_regex_match_full always returns
I have a bit of php code like this: $test = <!--my comment goes
I am testing a C++ source and I want to comment out some part
When editing Lisp code, occasionally it's useful to entirely comment out a top-level definition,
Sometimes I need to temporarily comment out block headings for testing purpose, e.g.: i
I program Django/Python in emacs, and I would like things like {% comment %}
is it possible, that in php something, which was written as comment( like //comment...
How do I generate a default comment for cvs? I'd like every checkin comment

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.