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'
You can comment out multiple lines by using
=beginand=end, but they must be located at the beginning of the line.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.