Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there such a thing as the C#'s `#region` keyword in Ruby

Tags:

ruby

In C# I can use the #region keyword to separate blocks of code. Does something like it exist in Ruby?

like image 265
Roman Avatar asked Jun 14 '12 00:06

Roman


2 Answers

Short answer: no.

Long answer: There is no code folding or comment style convention enforced by the ruby language. You can use your own convention for grouping methods however and setup your text editor to fold code in a way that works well for you (http://vim.wikia.com/wiki/Folding).

like image 50
aubreyrhodes Avatar answered Nov 12 '22 10:11

aubreyrhodes


Many wont like this answer, but its simple, and it works

if region1=true

    #your code/comments here

end #region1

this is of course, if region1 is not a variable you need at that scope

like image 34
J3STER Avatar answered Nov 12 '22 10:11

J3STER